vendredi 8 mai 2015

Model promise causing template to use .content

I have a ember model that has a computed property which is a promise. I am trying to display the resolved value in my template and can only get it working if I do .content on the property, which doesn't feel right. Below is my code. (http://ift.tt/1DWSh5S)

App = Ember.Application.create();

App.Router.map(function() {
  // put your routes here
});

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return [
      this.store.createRecord('foo')
    ];
  }
});

App.FooModel = DS.Model.extend({
  name: Ember.computed(function() {
    return DS.PromiseObject.create({
      promise: Ember.RSVP.resolve('foo')
    });
  }),
  anotherName: Ember.computed(function() {
    return "Hello";
  }),
  otherName: "Hello"
});

Template:

<ul>
{{#each model as |item|}}
  <li>{{item.name}} {{item.anotherName}} {{item.otherName}}</li>
{{/each}}
</ul>

I was expecting my use of DS.PromiseObject to handle the complexity I am seeing why isn't it? How can I ensure my template doesn't know that there is a promise backing the value?




Aucun commentaire:

Enregistrer un commentaire