Quantcast
Viewing all articles
Browse latest Browse all 4827

Using promises in a route's model

@nullnillzero wrote:

All,
I'm trying to figure out how I can use dynamic data from a promise in a model then return it to a template using handlebars.

Right now I've got this

myroute,js
export default Ember.Route.extend({
model() {
return new Ember.RSVP.Promise(function(resolver) {
let myData = new Array();
console.log(DynamicItems.compute().then(function(resolver){ /*DynamicItems is a helper I've imported*/
myData = resolver;
}));
}
});

my-component.hbs
<ul>
{{#each people as |elem|}}
<li>{{elem}}</li>
{{/each}}
</ul>

mytemplate.hbs
{{my-component people=model}}

What is being returned the the promise object, not the data. What's the most straight forward way to solve this?

tyia

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles