我正在使用ng-repeat數組json值。但我想從UI(HTML)中刪除重複的值。 贊Car值重複,所以我想刪除重複的鍵值。它應該來一次。如何刪除角度js ng-repeat中的重複鍵值?
var app = angular.module('testApp',[]);
app.controller('testCtrl',function($scope){
$scope.res ={};
$scope.res.fsus = [
{
"statusMessageType": {
"MasterConsignment": {
"ReportedStatus": {
"ReasonCode": "var"
}
}
}
},
{
"statusMessageType": {
"MasterConsignment": {
"ReportedStatus": {
"ReasonCode": "car"
}
}
}
},
{
"statusMessageType": {
"MasterConsignment": {
"ReportedStatus": {
"ReasonCode": "car"
}
}
}
},
{
"statusMessageType": {
"MasterConsignment": {
"ReportedStatus": {
"ReasonCode": "car"
}
}
}
},
{
"statusMessageType": {
"MasterConsignment": {
"ReportedStatus": {
"ReasonCode": "ban"
}
}
}
}
];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="testApp" ng-controller="testCtrl">
<li ng-repeat="test in res.fsus track by $index">
<span class="step"> {{test.statusMessageType.MasterConsignment.ReportedStatus.ReasonCode}}
</span>
</li>
</body>
我正在嘗試這一個。但它給我fsus未定義。 –
你需要把$ scope.res.fsus,檢查演示 – Sajeetharan
我putting。但我不知道。它爲什麼要來。 –