我正在使用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。但我不知道。它为什么要来。 –