我有以下对象。
$scope.sampleObj =
{
"id": 10000,
"transactionid": "gec43434",
"status": "COMPLETED",
"session_id": "TTYUU455667"
}
现在我需要使用ng-repeat
在文本区域的Label和值中显示此对象键。基本上我想在对象属性上使用ng-repeat
,是否可能?
我必须使用类似的东西:
<div ng-repeat="eachProp in sampleObj">
<label> {{eachProp.key}} </label> <textarea ng-model="eachProp.value"> </textarea>
</div>
答案 0 :(得分:1)
是的,你可以通过ng-repeat迭代一个对象。 你想要得到这个:
$(document).ready(function() {
var listAll = ["X1", "ANTENNA SYSTEMS 00000000AS", "Security & Wrokf 00000000CS", "MICROWAVE & COMM 00000000MC", "MICROWAVE SENSOR 00000000MT", "PLANNING & PROJE 00000000PG", "MECHANICAL SYSTE 00000000MS", "ELECTRO-OPTICAL 00000000EO", "SATCOM EXPERIMEN 00000000SE", "QUALITY ASSURANC 00000000QA", "QUALITY ASSURANC 00000000QC", "DATA PRODUCTS SO 00000000DP"];
var lstfiltered = ["X2"];
for (i = 0; i <= listAll.length - 1; i++) {
console.log(listAll[i]);
var string = listAll[i].toLowerCase();
var substring = "lan";
if (string.indexOf(substring) !== -1) // compare with string converted by toLowerCase()
{
lstfiltered.push(listAll[i]); // Push original string.
}
}
console.log(lstfiltered);
});
参阅文档toMillis()
JSfiddle链接:https://docs.angularjs.org/api/ng/directive/ngRepeat