【发布时间】:2015-11-10 17:02:15
【问题描述】:
我希望我的选项列表以英国开头。
html:
<select class="form-control" name="country" id="country-choice">
<option ng-repeat="x in ages | orderBy: COUNTRY==='United Kingdom of Great Britain and Northern Ireland'" value="">{{ x.COUNTRY }}</option>
</select>
json:
{
"COUNTRY":"United Kingdom of Great Britain and Northern Ireland",
"SEX":"Male",
"Value":"79"
},
请不要担心 json 的接线,它工作正常。我只想让我的列表以英国开头并显示其他国家。使用过滤器英国隐藏所有其他国家,我不想要这个。我希望英国在顶部,然后是其余的......即阿富汗等,因为它将按字母顺序排列。
【问题讨论】:
-
对数组进行预排序并将英国放在首位? orderBy 只需要属性名称来排序。
-
天哪,你是对的,就这么简单!
标签: javascript json angularjs