我试图通过@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!! } });
您应该使用以下内容来获取事件提供的值:
<child-cmp (myEvent)="invoke($event)"'></child-cmp>'
这样,childCmp的invoke方法将作为参数接收您在发出myEvent自定义事件时提供的值.
希望它能帮到你,蒂埃里
原文地址:https://www.jb51.cc/angularjs/142327.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。