来自控制台的ember触发器动作

时间:2014-09-24 05:30:34

标签: javascript ember.js console action

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/

1 个答案:

答案 0 :(得分:1)

这是一个非常古老的主题,但是你可以从devtools开始:

App.__container__.lookup('component:post-summary').send('toggleBody');