ember.js - Returning an array from the model -
i new ember , trying data model array.
currently doing:
var playerlist = app.player.find().toarray();
but it's not returning me array of players it's returning array of objects? ex:
<app.player:ember311:1>,<app.player:ember332:2>,<app.player:ember338:3>,<app.player:ember344:4>,<app.player:ember350:5>,<app.player:ember356:6>,<app.player:ember362:7>,<app.player:ember368:8>
any appreciated. thanks!
app.player.find()
returns promise, , therefore should wait until records loaded before doing operations on them. question it's not entirely clear how player objects like. players, , player's properties, like:
var playerlist = app.player.find().then(function (result) { // callback fire when array loaded // , correct way records result.objectat(0).get('name'); // assuming "name" property of model // here can loop on obejcts result.foreach(function(item) { console.log(item.get('name')); }); });
hope helps.
Comments
Post a Comment