What is called in the Controller after SetupController?

Is there a method called in a controller after a route does a SetupController?

What are you my options?

No, but you can easily do it yourself if you want.

App.FooRoute = Ember.Route.extend({
    setupController: function(controller, model) {
        this._super(controller, model);
        Ember.tryInvoke(controller, 'afterSetup');
    }
});
1 Like

Excellent, thanks! Works like a charm

Another alternative is this

export default Em.Route.extend({})
  detectController: function() {
    console.log('hi')
  }.observes('setupController').on('init')
});

Dunno if there are any drawbacks though, maybe it breaks somewhere, but off the top of my head, I don’t think so.

I don’t think that will work. The observes() function is only called when the setupController property changes. In this case, setupController isn’t changing, it’s just being called.

Here’s a JSBIN → http://emberjs.jsbin.com/fohofoqaxusu/1/edit

It’s possible, but I don’t know if there’s something horribly wrong with it. Reading up on it though.

That’s only working because you have the .on('init') included. Right now it’s only firing when the controller singleton is created, which means it’ll only fire the first time the controller is setup from the route.

1 Like

Sweet, thanks for clarifying that!

Here is a JSBin I made a while back that shows the route hook order:

http://emberjs.jsbin.com/rolo/1

1 Like