如何从子组件 Angular 7 将两个参数传递给父组件函数?

Kar*_*ena 4 angular-cli angular

我有一个要求,我必须从子组件调用父组件函数。显而易见,我们可以使用@Output参数 withEventEmitter来实现这一点。但这里的挑战是父组件是这样的

func(param1,param2){
}
Run Code Online (Sandbox Code Playgroud)

我想从孩子那里调用这个方法,所以我使用了类似的方法。

@Output() childToParent = new EventEmitter<object>();

callParentMethod(){
this.childToParent.emit({param1:this.param1,param2:this.param2});
}
Run Code Online (Sandbox Code Playgroud)

它能够调用我见过的函数,但参数没有被传递。谁能建议我做错了什么或遗漏了什么?

Adr*_*rma 9

尝试这样:

父级.html

<child  (childToParent)="func($event.param1, $event.param2)"></child>
Run Code Online (Sandbox Code Playgroud)

工作演示