jeudi 19 avril 2018

How to make template wait until route loads data controller depends on?

In a template i have a field:

Hello

And in the controller:

thisIsIt: function()
{
   return this.get("underdata").get("length") // 1
}.property('underdata')

And in router:

setupController: function(controller, model) 
{
   this.store.find('underdata', {id: 1 }).then(function(underdata) // 2
    {
        controller.set("underdata", underdata); // 3
    });
}

The order of call is: 2,1,3. So controller to satisfy template tries to get a length of underdata. But underdata is undefined, because 3 was not called yet. After throwing an error 3 is eventually called.

How to make controller wait until setupController gets the necessary data from underdata?




Aucun commentaire:

Enregistrer un commentaire