ember.js - Getting data from DS.PromiseArray in EmberJS -


i'm new emberjs , i'm having trouble working promises.

here router:

  this.resource('menus', function(){     this.resource('menu', {path: '/:menu_id'}, function(){       this.resource('submodule', {path: '/:submodule_id'});     });   }); }); 

i have nested routes, , child route returns menuss object based on given id. here menuroute:

app.menuroute = ember.route.extend({   model: function(params){     return this.store.find('menuss', params.menu_id);   }     }); 

here models:

app.menuss = ds.model.extend({   name: ds.attr('string'),   submodule: ds.hasmany('submodule', {async:true}) });  app.submodule = ds.model.extend({   name: ds.attr('string'),   content: ds.attr('string') }); 

the 'submodule' attribute of menuss model contains array of submodule model id's. inside menu template, i'm receiving menuss object , want display submodules each menu item has.

however, when call {{this.submodule}}, returns <ds.promisearray:ember488>. how can contents submodule array?

i looked @ similar questions use then() method, can't seem figure out here.

in template you'll want iterate property since it's array, ember/handlebars deal synchronicity of promisearray.

{{#each item in submodule}}   {{item.name}} {{/each}} 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -