zpy*_*dee 7 angularjs hottowel angular-ui-bootstrap
<select class="form-control" data-ng-options="t.name for t in vm.types"
data-ng-model="vm.object.type"></select>
Run Code Online (Sandbox Code Playgroud)
上面的代码显然以标准的表单控制方式显示基本下拉列表.我一直试图弄清楚如何使用Angular的ui-bootstrap指令将其转换为按钮样式下拉列表,但似乎无法获得任何结果.有没人试过这个?
我希望你已经找到了答案,但也许其他人会觉得这很有用.之前的答案是指常见的下拉菜单,而不是按钮下拉菜单.这是一个例子,但没有hg-option的好处,而我没有使用select而是一个按钮.
<div class="input-group">
<div class="input-group-btn" ng-class='{open: open}'>
<button class="btn dropdown-toggle"
data-toggle="dropdown"
ng-click='open=!open'>
Action<span class="caret"></span></button>
<ul class="dropdown-menu">
<li ng-repeat="choice in choices"
ng-click="setChoiceIndex($index);$parent.open =!$parent.open">
<a href="#">{{choice}}</a></li>
</ul>
</div>
<input type="text" ng-model="choices[index]" class="form-control">
</div>
Run Code Online (Sandbox Code Playgroud)
其中choices是将在下拉列表中显示的字符串数组,而index是控制器范围中将反映所选选项的另一个变量.
| 归档时间: |
|
| 查看次数: |
23512 次 |
| 最近记录: |