1
I have 3 Components, a Component Father, B Son and a C Son
export class A Parent implements OnInit {
constructor() {
}
}
In Componen B I have a method to create user
export class B Parent implements OnInit {
constructor() {
}
create() {
this.userService.create()
.subscribe((res) => {
// Call other method in Component C
//this.card.emit(null)
});
}
}
And now I have a Component C Where I need call the list method
export class C Parent implements OnInit {
constructor() {
}
ngOnInit() {
this.getUsers();
}
getUSers() {
this.userService.getUsers()
.subscribe((res) => {
this.users = res
});
}
}
and Finally my view
<div class="col s6">
<list-administrators ></list-administrators>
</div>
<div class="col s6" *ngIf="card == 'create'">
<create-administrator></create-administrator>
</div>
<div class="col s6" *ngIf="card == 'details'">
<details-administrator></details-administrator>
</div>
<div class="col s6" *ngIf="card == 'edit'">
<edit-administrator></edit-administrator>
</div>
In component B, I have a method to create a user, when he create, I would call the listing of the other child C, how can I do ?