Pass Params from 'Model' Hook to 'setupController' hook in route handler

Hi,

There is another few ways to do it:

  1. this.paramsFor(‘your_route’) in setupController

  2. Like dknutsen mentions, take them from the RouteInfo of the transition object that is passed into setupController() transition.to.params.

But with the “to” you have to bear in mind it’s the tail of the route so if ember.js has (like the ball-ache it can be) taken the liberty of moving into and appending “.index” to your route, it will appear like params is empty which means you gotta look up one level to get them. Something like this:

    let routeinfo = transition.to.find(function(item, index, array) {

    // Bit daft that I have to do this but it's because the .index does not get the params passed

        return typeof(item.params.cat_id) != "undefined";

    });

    

    controller.set('exitroute', routeinfo ? routeinfo : transition.from);