![](/img/trans.png)
[英]calling parent component function from child of siblings component in angular
[英]Angular calling function in child component from parent component
從子組件調用父組件中的函數時出錯。 我想我在從父組件調用func()
時在子組件中犯了一些錯誤
parent component
func(){...........}
parent.html
<child (func)="func()"></child>
child.component.ts
@Output func = new EventEmitter();
someOtherFunc(){
this.func.emit();
}
嘗試這個,
父組件.html
<child (func)="func($event)"></child>
子組件.ts
@Output() func: EventEmitter<any> = new EventEmitter();
someOtherFunc(){
this.func.emit(null);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.