angularjs - Angularjs data-toggle = 下拉菜单不使用选择选项
问题描述
在我的代码中,我使用了简单的下拉绑定和使用 ng-repeat 的选项,但是当我绑定它时,由于启用了一些额外的类可能在 javascript 中,它什么也不显示。我的正常代码是:
<div class="col-md-6 col-sm-12">
<label>Select Employee</label>
<select class="form-control show tick" id="selectEmp" name="toEmployeeCode" required="" ng-model="toEmployeeCode">
<option value="">Select Team Member</option>
<option ng-repeat="x in AllEmployee" value="{{x.EmployeeCode}}">{{x.FirstName}} {{x.MiddleName}} {{x.LastName}}</option>
</select>
</div>
但是当它加载显示
<div class="btn-group bootstrap-select form-control tick">
<button type="button" class="btn dropdown-toggle bs-placeholder btn-round
btn-simple" data-toggle="dropdown" role="button" data-id="selectEmp"
title="Select Team Member" aria-expanded="false">
<span class="filter-option pull-left">Select Team Member</span>
<span class="bs-caret"><span class="caret"></span></span>
</button>
<div class="dropdown-menu" role="combobox">
<ul class="dropdown-menu inner" role="listbox" aria-expanded="false">
<li data-original-index="0" class="selected">
<a tabindex="0" class="" data-tokens="null" role="option" aria-
disabled="false" aria-selected="true">
<span class="text">Select Team Member</span>
<span class="glyphicon glyphicon-ok check-mark"></span>
</a>
</li>
<li data-original-index="1">
<a tabindex="0" class="" data-tokens="null" role="option" aria-
disabled="false" aria-selected="false">
<span class="text ng-binding"> </span>
<span class="glyphicon glyphicon-ok check-mark"></span>
</a>
</li>
</ul>
</div>
<select class="form-control show tick ng-pristine ng-untouched ng-
invalid ng-invalid-required" id="selectEmp" name="toEmployeeCode"
required="" ng-model="toEmployeeCode" tabindex="-98" aria-
required="true">
<option value="">Select Team Member</option>
<option ng-repeat="x in AllEmployee" value="EMP-1004" class="ng-
binding ng-scope">ABC</option>
<option ng-repeat="x in AllEmployee" value="EMP-1007" class="ng-
binding ng-scope">PQR</option>
<option ng-repeat="x in AllEmployee" value="EMP-1008" class="ng-
binding ng-scope">ASD</option>
<option ng-repeat="x in AllEmployee" value="EMP-1009" class="ng-
binding ng-scope">ZXC</option>
<option ng-repeat="x in AllEmployee" value="EMP-1010" class="ng-
binding ng-scope">HUK</option>
</select>
</div>
但是当我使用我的代码时它不起作用它不会显示
我使用 angularjs
var app = angular.module('App', ['ui.router','ui.bootstrap']);
解决方案
不要使用ng-repeat
in <option>
,它工作不正确。在 select 中使用ng-options代替。
推荐阅读
- javascript - JavaScript对象作为计数器不递增
- concurrency - 为什么要换!即使 Atom 的值没有改变,也要重试?
- excel - 如何将具有变量的另一个单元格的乘积放入一个单元格中?
- jquery - 当它们有多个时,我如何触发每个按钮?使用 jQuery
- html - 如何使用 Bootstrap 在 Jekyll 中包装文本而不是代码块?
- spring - Spring Security:认证后Referer始终登录页面
- redux - 使用中间件时属性“类型”的redux错误
- mono - gtk#: 按列名删除列
- python - 确认浏览器预取导致删除
- c++ - C++ 在不同的线程中改变向量