1
votes

So, basically I am working on this app where I want to redirect users with incomplete profiles to fill it out. I know this can be done by using the afterModel hook within the router for EACH route, however, I was wondering if there's a hook that is called for ALL routes that could be used for this. This way I don't have to keep adding this logic in the afterModel for any new route I add.

EDIT:

What I ended up doing was this:

in controllers:

Blocks.ApplicationController = Ember.Controller.extend({
currentPathDidChange: function() {
    var path = this.get('currentPath');
    window.document.title = path;
}.observes('currentPath')

});

1

1 Answers

2
votes

Add it to the ApplicationRoute beforeModel/afterModel hook, it's the root of the app and always called at least once.

If you want it to happen every time they transition routes, you can observe currentPath in the ApplicationController and fire things there. Ember will keep the value up to date as you change routes.

http://emberjs.jsbin.com/opOxoKEf/1/edit