0
我試圖按字母順序排列基於JSON陣列上的名單,但我似乎無法得到它的工作。我現在的代碼看起來像這樣。這裏是對的jsfiddle http://jsfiddle.net/hxxLaxL3/訂購JSON按字母順序排列在angular.js當沒有鍵/值的關聯
HTML
<div ng-app>
<div ng-controller="Ctrl">
<li ng-repeat="f in friends | orderBy:'f'">{{f}}</li>
</div>
</div>
角鏈路
function Ctrl($scope) {
$scope.friends =
['C',
'B',
'Z',
'S'];
}
輸出
- Ç
- 乙
- ž
- 小號
所需的輸出
- 乙
- Ç
- 小號
- Ž
'$ scope.friends = [ 'C', 'B', 'Z', 'S']排序();'是最簡單的可能ORDERBY – Rhumborl 2014-12-01 15:37:17
: '的toString()' HTTP ://stackoverflow.com/questions/14493116/how-to-make-orderby-filter-work-on-array-of-strings – micha 2014-12-01 15:53:20