App = Ember.Application.create();
posts = [{
title: "Rails is omakase",
body: "There are lots of à la carte software environments in this world."
}, {
title: "Broken Promises",
body: "James Coglan wrote a lengthy article about Promises in node.js."
}];
App.IndexRoute = Ember.Route.extend({
model: function() {
return posts;
}
});
App.PostSummaryComponent = Ember.Component.extend({
actions: {
toggleBody: function() {
this.toggleProperty('isShowingBody');
}
}
});
如果我想从浏览器控制台调用toggleBody函数,我该怎么办? 上面的代码显示在ember.js文档http://emberjs.com/guides/components/handling-user-interaction-with-actions/
中答案 0 :(得分:1)
这是一个非常古老的主题,但是你可以从devtools开始:
App.__container__.lookup('component:post-summary').send('toggleBody');