【发布时间】:2016-10-12 10:35:55
【问题描述】:
关于 Angular2 指令,我想使用 outputs 而不是使用 @Output,因为我有很多自定义事件并且想要保持 DRY。
但是,我有TypeError: Cannot read property 'subscribe' of undefined,我不知道为什么会这样。
http://plnkr.co/edit/SFL9fo?p=preview
import { Directive } from "@angular/core";
@Directive({
selector: '[my-directive]',
outputs: ['myEvent']
})
export class MyDirective {
constructor() {
console.log('>>>>>>>>> this.myEvent', this.myEvent);
}
}
这是使用该指令的应用组件
【问题讨论】:
标签: angular angular2-directives