我正在使用Angularjs,我需要按字母順序設置我的下拉列表。如何使用Angularjs在ng選項中使用字母順序?
這裏是NG選項:
<div class="form-group">
<label>Branch : <i class="mandate">*</i></label>
<select class="form-control input-md" ng-model="query.branch" ng-options="showName(branch.branchName) as showName(branch.branchName) for branch in baseBranches | orderBy:'toString()'" name="branchName">
<option value="" selected>Select Branch</option>
</select>
<span class="error" ng-show="search_form.branchName.$error.required">Branch is required</span>
</div>
我是新來Angularjs。
可能重複http://stackoverflow.com/questions/12310782/sorting-dropdown-alphabetically- in-angularjs –
@Sa E Chowdary嘗試了它,但沒有工作,因爲我正在使用函數showname刪除我的下拉數據中的數字和空格。 –
好吧,我們不能猜測你對你的功能調用正確的做什麼.....所以根據你提供的數據來回答。作爲接受的答案,你需要通過 –