I have 3 components, one component A Father, Son B, and Son C
export class A Parent implements OnInit {
constructor() {
}
}
In Compose 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 to 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 creates it, I would like to call the other child's C listing, how can I do it?