Reputation: 888
I have a requirement in which I have to call a parent component function from child. As obvious we can use @Output
parameter with EventEmitter
to achieve this. But the challenge here is the parent component is something like this
func(param1,param2){
}
I want to call this method from the child so I used something like this.
@Output() childToParent = new EventEmitter<object>();
callParentMethod(){
this.childToParent.emit({param1:this.param1,param2:this.param2});
}
It is able to call the function that I have seen but the parameters are not getting passed. Can anyone please suggest what am I doing wrong or missing something?
Upvotes: 4
Views: 2539
Reputation: 22213
Try like this:
parent.html
<child (childToParent)="func($event.param1, $event.param2)"></child>
Upvotes: 9