[英]Sort list by property name AngularJS
I have a complex object that looks like: 我有一个看起来很复杂的对象:
{
'street35':[
{'address154': 'name14'},
{'address244': 'name2'}
],
'street2':[
{'address15': 'name1'},
{'address234': 'name2'}
]
}
I'm binding it to the html using the (value, key) in object attribute that angular.js provides. 我使用angular.js提供的对象属性中的(值,键)将其绑定到html。 I want to order by the value in this case by the street name.
在这种情况下,我想按街道名称的值排序。 Any suggestions?
有什么建议么?
You can try this code: 您可以尝试以下代码:
JS: JS:
$scope.streetsObject = {
'street35':[
{'address154': 'name14'},
{'address244': 'name2'}
],
'street2':[
{'address15': 'name1'},
{'address234': 'name2'}
]
}
HTML: HTML:
<div ng-repeat="street in streetsObject | orderBy">
<span ng-repeat"name in street">
</span>
</div>
The code supposes that you are using angular 1.3.0+. 该代码假定您正在使用angular 1.3.0+。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.