0
私はまだこれと角度2でかなり新しいです。私はあなたに聞こうとしていることがかなり基本的だと感じていますが、私はそれの周りに私の頭を包むことはできません。typescriptイベント親から子へ
@Component({
template:'<html> <router-outlet></router-outlet> </html>'
})
export class ParentComponent implements OnInit{
@ViewChild(childComponent) childComponent:ChildComponent;
constructor(){}
ngOnInit(){
if(childComponent){
childComponent.myEvent.subscribe(row=>this.test(row));
}
}
test(row:any){
alert("I Fired");
}
}
@Component({
template:'<some html></some html>'
})
export class ChildComponent implements OnInit{
myEvent = new EventEmitter();
constructor(){}
ngOnInit():void{
this.myEvent.emit("some info");
}
}
だから私が午前問題は親にそれがイベントchildComponent
に加入しようとしたときということです。だから、私はあなたがあまりにものようなものをナビゲートすることができ、我々はそれが子コンポーネントが含まれているコンテナ呼び出すコンポーネントを持っています無効である。どんな助けもありがとう。ありがとうございました。