簡體   English   中英

來自父組件的子組件中的角度調用函數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM