I want to show below data in ascending order in select box.
Data is as under :-
[
{
"value": "MKZ_2017_LCN2014",
"text": "林肯MKZ"
},
{
"value": "MKX_2016_LCN2014",
"text": "林肯MKX"
},
{
"value": "MKC_presidential_LCN2014",
"text": "林肯总统系列MKC(Oasis)"
},
{
"value": "MKZ_2015_360used_LCN2014",
"text": "林肯MKZ(360)"
}
]
View code is :-
<select
class="select-modal"
ng-model="key3"
id="model-03-1"
name="third-primary-model"
ng-options="nameplate.text for nameplate in thirdLevelDropDown track by nameplate.value"
ng-change="getCarModel3(key3)"
>
<option value="">Select</option>
</select>
I want to sort select box on the name of text.
Appreciate your help
You can do this, Use | orderBy:'text'
| orderBy:'text'
<select class="select-modal" ng-model="key3" id="model-03-1" name="third-primary-model" ng-options="nameplate.text for nameplate in thirdLevelDropDown | orderBy:'text'" ng-change="getCarModel3(key3)">
<option value="">Select</option>
</select>
这对我有用。
ng-options="nameplate.text for nameplate in (models | orderBy: 'text') track by nameplate.value"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.