[英]AngularJS: Sorting Strings With Spaces Using orderBy
我正在進行ng-repeat,其中:
<a ng-repeat="contact in contacts | orderBy:'name'">
{{contact.name}}
</a>
我嘗試過謂詞:name,-name,name.substr(0,3)
聯系人的“名稱”屬性類似於“約翰·史密斯”,“貝蒂·福特”,“霍基·皮爾斯”等。
ng-repeat有效,但orderBy無效。
是否存在我的字符串可能無法成功排序的原因?
1:orderBy僅適用於數組-請參見http://docs.angularjs.org/api/ng.filter:orderBy
您的“聯系人”是什么?
2:嘗試
<div ng-repeat="contact in contacts | orderBy:'name'">
<a>{{contact.name}}</a>
</div>
這是您的案例的工作鏈接
希望對您有幫助
'http://plnkr.co/edit/EhV5RHszZns5qTHM8qBu?p=preview'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.