通常,我需要遍历Ember.ArrayProxy对象的内容.
例1,我需要构建一个ID列表:
var loc = myArrayProxy.get('length') || 0,
ids = new Array(),
idsList;
while(--loc >= 0) {
var curObject = myArrayProxy.objectAt(loc);
ids.push(curObject.id);
}
idsList = ids.join(',');
Run Code Online (Sandbox Code Playgroud)
例2,我需要构建一个原始对象数组(不是Ember.Object):
var loc = myArrayProxy.get('length') || 0,
newContent = new Array();
while(--loc >= 0) {
var curObject = myArrayProxy.objectAt(loc);
newContent.push({
id: curObject.id,
name: curObject.name
});
}
Run Code Online (Sandbox Code Playgroud)
问题:有更好的方法吗?"while( - loc> = 0)"对我来说似乎很糟糕.
ember.js ×1