1
以下是使用ES5演示Angular 2中输出的示例代码。但是我得到一个TypeError: Cannot read property 'subscribe' of undefined
错误。ES5中的Angular2输出?
var SampleComponent10 = ng.core.Component({
selector: "sampleten",
outputs: ["click"],
template: ""
}).Class({
constructor: function(){
setInterval(function(){
this.click.next({});
}.bind(this), 10000)
}
})
var SampleComponent11 = ng.core.Component({
selector: "sampleeleven",
directives: [SampleComponent10],
template: "<sampleten (click)='clicked($event)'></sampleten>"
}).Class({
constructor: function(){
this.clicked = function(e){
console.log(e);
console.log("Clicked");
}
}
})
似乎在SampleComponent11的模板中有一些错误。但我没能抓住它
但是为什么'outputs'财产不能正常工作,请参阅。为什么我们需要手动将其分配给EventEmitter的新实例? –
因为您的类组件的属性点击是未定义的。 – yurzui
而这条线 会导致错误 –
yurzui