mardi 5 juin 2018

Resolve a string from a Ember model computed promise

I have a computed property on an EmberJS model:

imageUrl: computed('image', function () {

    let promise = new RSVP.Promise(function (resolve, reject) {
        resolve('image.png');
    });

    //
    return DS.PromiseObject.create({promise: promise});
}),

Which works, however the model resolves the promise to an object so I have to do something like:

resolve({image: 'image.png'});

To actually access the value in the template, using something like:



Rather than just:



Obviously the problem appears to be to do with DS.PromiseObject but I have no idea what to use instead and the docs are not very helpful in this regard.




Aucun commentaire:

Enregistrer un commentaire