2014-09-24 72 views
1
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

這是一個非常古老的線程,但devtools你可以這樣做:

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