1
var selectCheckbox = [];
for (i = 0; i <= escConfigForm.chapters.size; i++) {
if (escConfigForm.chapters['i']) {
selectCheckbox.push({
id: $scope.chapters['i'].id,
name: $scope.chapters['i'].name
});
}
console.log(selectedCheckbox);
我创建一个数组来返回对象到它其中来自$scope.chapters
它看起来像:iterrating通过对象和数组存储
[{"name":"Chapter 9: Negative Messages","id":"832115"},{"name":"Chapter 13: Proposals, Business Plans, and Formal Business Reports","id":"832124"}].
同时我想他们escConfigForm.chapters
比较哪个给我看一个物体(0:true 1:true 2:true);
escConfigForm.chapters.size
/escConfigForm.chapters.length
好像是undefined
。
对象没有'length'属性,但是可以执行'Object.keys(object).length'。 – elclanrs 2014-10-01 01:51:10