我有這樣的陣列:濾波數據和顯示每一個類型的第一項
控制器:
$scope.data = [
{id:1, name:"a", type: "letter"},
{id:2, name:"1", type: "number"},
{id:3, name:"b", type: "letter"},
{id:4, name:"2", type: "number"},
{id:5, name:"c", type: "letter"},
{id:6, name:"3", type: "number"},
];
$scope.dataLimit = 1;
HTML:
<div ng-repeat="user in data | orderBy: 'type' | limitTo: dataLimit">
<label ng-bind="'name: ' + user.name"></label>
<label ng-bind="'type: ' + user.type"></label>
我試圖過濾數據按類型,我想顯示每種類型的第一個數據,在這種情況下將是:
- 名稱:A型:信
- 名稱:1種類型:數
感謝兄弟,你真棒! – DavidAlzate88