I have spent a lot of time trying to implement what ought to be a simple thing in Ember: bubbling an action from a component to the application controller. The docs say that in order to propogate an action then all I need to do is declare the action when I declare the template:
{{#if isLoggedIn}}
{{menu-bar authenticate="authenticate"}}
{{/if}}
...and then send the action from the component (which is nested in the login route):
authenticate: function() {
//code omitted for brevity
this.sendAction();
}
...which should be received by the application controller:
user: Ember.inject.service(),
isLoggedIn: false,
actions: {
authenticate: function(){
console.log('authenticated!');
this.set('isLoggedIn', this.get('user').isLoggedIn());
}
}
but it isn't. And I'm wasting a lot of time trying to work out why.
I'm sure it's really obvious but if someone can tell me what I'm doing wrong I would greatly appreciate it.
Aucun commentaire:
Enregistrer un commentaire