【发布时间】:2019-05-21 07:28:40
【问题描述】:
我想从孩子向父母发出一个事件,但有一些论据。
子组件 javascript
import Component from '@ember/component';
export default Component.extend({
tagName: 'li',
actions: {
favoriteWasClicked() {
const organization = this.get('organization');
// organization.id value equal to 'facebook' here in my app
// we're gonna send its id to parent component "orgs" like an argument of clicked method
this.clicked(organization);
}
}
});
父组件.hbs模板
{{child-component
clicked=(action "favoriteClicked" value="organization.id")
}}
父组件javascript控制器文件
import Controller from '@ember/controller';
export default Controller.extend({
actions: {
favoriteClicked(orgId) {
console.log(orgId);
}
}
});
我在 console.log(orgId); 中得到 undefined 为什么?我错过了什么
谢谢!
【问题讨论】:
标签: javascript ember.js