mercredi 31 mai 2017

Ember transitionTo and set controller attribute in callback

I have Ember code to transitionTo some route & I want to set controllerAttr1 on my.route

this.get('router').transitionTo("my.route").then(function (newRoute) {
    newRoute.controller.set("controllerAttr1", controllerAttr1); // This code is called later
});

In my.route, I have a check for controller.controllerAttr1

model: function (params) {

},

setupController: function setupController(controller, model) {
    // Issue us below check is executed before the callback code which sets "controllerAttr1"
    if (controller.controllerAttr1) {
        //Do something
    }
}

However, my issue is this check for controller.controllerAttr1 happens before the callback code is executed

newRoute.controller.set("controllerAttr1", controllerAttr1);

How do I fix this ?




Aucun commentaire:

Enregistrer un commentaire