我有如下所示的代码,我只是想知道如何在路线事件中触发另一个事件。想法?
App.MyRoute = Ember.Route.extend({
events: {
eventOne: function() {
// do something
},
eventTwo: function() {
// how do I call eventOne() here?
},
}
});
答案 0 :(得分:2)
您可以使用events.eventOne()
作为上下文调用this
:
App.IndexRoute = Ember.Route.extend({
events: {
eventOne: function() {
console.log('You got me!');
},
eventTwo: function() {
this.events.eventOne();
},
}
});