Html 如何使用Angularjs在ng选项中使用字母顺序?
我正在研究Angularjs,我需要按字母顺序设置下拉列表 以下是ng选项:Html 如何使用Angularjs在ng选项中使用字母顺序?,html,angularjs,Html,Angularjs,我正在研究Angularjs,我需要按字母顺序设置下拉列表 以下是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.branchNam
<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>
分支机构:*
选择分支
分支是必需的
我是安格拉斯的新手 试试这个
<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:'branchName'">
<option value="" selected>Select Branch</option>
</select>
<span class="error" ng-show="search_form.branchName.$error.required">Branch is required</span>
</div>
分支机构:*
选择分支
分支是必需的
试试这个
<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:'branchName'">
<option value="" selected>Select Branch</option>
</select>
<span class="error" ng-show="search_form.branchName.$error.required">Branch is required</span>
</div>
分支机构:*
选择分支
分支是必需的
您可以在angular js中使用Order by filter
<select class="form-control input-md"
ng-model="query.branch"
ng-options="showName(branch.branchName) as showName(branch.branchName) for branch in baseBranches | orderBy:'branchName'" name="branchName">
<option value="" selected>Select Branch</option>
</select>
您可以在angular js中使用Order by过滤器
<select class="form-control input-md"
ng-model="query.branch"
ng-options="showName(branch.branchName) as showName(branch.branchName) for branch in baseBranches | orderBy:'branchName'" name="branchName">
<option value="" selected>Select Branch</option>
</select>
ng repeat对我有效,请检查
分支机构:*
选择分支
{{item}}
ng repeat对我有效,请检查
分支机构:*
选择分支
{{item}}
appeable duplicate@Sa E Chowdary尝试了它,但不起作用,因为我正在使用函数showname删除下拉数据中的数字和空格。嗯,我们猜不出你在函数调用中做了什么……因此根据你提供的数据进行了回答。作为公认的答案,你需要通过传递订单的密钥。如果你在$scope.basebranchs中提供数据,那么我们可以给你预期的输出可能重复@Sa E Chowdary尝试过但没有工作,因为我正在使用showname函数删除下拉数据中的数字和空格,我们猜不出你在函数调用中做了什么……因此根据你提供的数据回答。作为公认的answe,你需要将密钥传递给order by如果你在$scope.baseBranchs中提供数据,那么我们可以给你ecpected output@Nitheesh它的正确格式,但我的json数据是这种格式:“branchName”:“0082 MAHESANA”,@Nitheesh i被用作showname函数来删除我下拉数据中的数字和空格。要求按字母顺序显示,然后尝试使用orderBy:showName(branch.branchName)。我不确定这次事件的结果。请检查。@ChethanaC您确定名称的格式是唯一的,比如[number][space][word]?@Nitheesh这是正确的,但我的json数据的格式是:“branchName”:“0082 MAHESANA”;@Nitheesh i被用作showname函数来删除我下拉数据中的数字和空格。要求按字母顺序显示,然后尝试使用orderBy:showName(branch.branchName)。我不确定这次事件的结果。请检查。@ChethanaC您确定名称的格式是唯一的,比如说[number][space][word]?