简体   繁体   English

余烬从控制台触发动作

[英]ember trigger action from console

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');
    }
  }
});

What do I suppose to do if I want to call toggleBody function from my browser console. 如果要从浏览器控制台调用toggleBody函数,该怎么办。 The above code is presented in ember.js document, http://emberjs.com/guides/components/handling-user-interaction-with-actions/ 上面的代码在ember.js文档中提供,该文档为http://emberjs.com/guides/components/handling-user-interaction-with-actions/

这是一个非常老的线程,但是可以通过devtools来执行:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM