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/來自控制檯的灰燼觸發器動作