我试图通过@Output传递参数,但被激活的函数只是接收'undefined'.有人可以告诉我通过@Output的EventEmitter传递参数的方法吗?例如:
var childCmp = ng.core.Component({
selector:'child-cmp',
outputs: ['myEvent']
}).Class({
constructor: function(){
this.myEvent = new ng.core.EventEmitter();
this.myEvent.emit(false);
}
});
var parentCmp = ng.core.Component({
selector:'parent-cmp',
template:'<child-cmp (myEvent)="invoke()"'></child-cmp>',
directives: [childCmp]
}).Class({
constructor:function(){},
invoke: function(flag){
// here flag is undefined!!
}
});
Run Code Online (Sandbox Code Playgroud)
Thi*_*ier 10
您应该使用以下内容来获取事件提供的值:
<child-cmp (myEvent)="invoke($event)"'></child-cmp>'
Run Code Online (Sandbox Code Playgroud)
这样invoke,您的方法childCmp将作为参数接收您在发出myEvent自定义事件时提供的值.
希望它对你有帮助,蒂埃里
Thierry的回答几乎是正确的,你需要在输出函数中传递$ event:
<child-cmp (myEvent)="invoke($event)"'></child-cmp>'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8612 次 |
| 最近记录: |