我在 angularJS 中有一个字符串数组,我想对其元素进行某种排序,我尝试了这段代码,但它不起作用,我不知道为什么有人有任何想法
<div id="cpntainer" data-ng-init="countries = ['Syria','Lebanon','Jordon','Egypt']">
Country Name <br />
<input type="text" data-ng-model="name" /> <br />
<ul>
<li data-ng-repeat="country in countries | filter:name | orderBy:country:false "> {{ country }} </li>
</ul>
</div>
您可以在 orderBy 子句中使用如下函数:
<li data-ng-repeat="country in countries | filter:name | orderBy:'toString()'"> {{ country }}</li>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)