【发布时间】:2017-10-29 08:36:02
【问题描述】:
作为问题的后续:Emit event from Directive to Parent element : Angular2
看起来当结构指令发出事件时,父组件没有收到它。
@Directive({ selector: '[appWidget]' })
export class WidgetDirective implements OnInit{
@Output() wdgInit: EventEmitter<any> = new EventEmitter();
@Input() set appWidget (wdg: any) {
//display stuff
}
ngOnInit {
this.wdgInit.emit();
}
widget.component.html:
<ng-container *ngFor="let wdg of widgets">
<div *appTwitterWidget="wdg" >
<ng-container>
widgetContainer.component.html:
<app-widget [widgets]="widgetList" (wdgInit)="containerDoSomthing()"></app-widget>
在这种情况下,我发现 containerDoSomthing() 永远不会被调用。
【问题讨论】:
标签: javascript angular typescript angular-directive