我刚开始使用angularJS而且我的ng-repeat有问题。因此,在我的component.js
文件中,我将$scope
声明为vm
并声明了一个对象数组:
vm.locOptionFields =
{
"locOptionFieldKey": 1,
"fieldID": "Allow additional material to be added to Orders that have been processed but not shipped",
"stringNum": 11,
"taskKey": 12,
"type": "checkbox",
"seqNum": 13,
"comboOptionRefKey": 1
},
{
"locOptionFieldKey": 2,
"fieldID": "Require requested delivery date",
"stringNum": 12,
"taskKey": 13,
"type": "number",
"seqNum": 14,
"comboOptionRefKey": 1
},
{
"locOptionFieldKey": 3,
"fieldID": "Default Requested Delivery Date into Promise Date",
"stringNum": 13,
"taskKey": 14,
"type": "combobox",
"seqNum": 15,
"comboOptionRefKey": 2
};
我想在我的.html文件中引用该信息,并使用ng-repeat
打印出每个对象的taskKey
。我试过这样做:
<li ng-repeat="loc in vm.locOptionFields">
{{loc.type}}
</li>
但所有正在做的就是给我空白列表项,每个元素对应一个元素。但是,当我打印出{{loc}}
时,它会打印出每个项目,仅针对第一个对象。它只是出于某种原因才识别第一个对象吗?