我刚接触过Javascript和AngularJS,目前正在尝试通过按钮实现下拉复选框(用于搜索过滤器)。我目前能够让下拉列表出现,但是当我选中复选框时,下拉列表立即关闭。当我再次打开下拉列表时,也不会将选中的项保存为选中项。下面是我在我的tpl.html中拥有的内容:
<div class="input-group-btn">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" bs-dropdown data-template-url="dropdown-template" data-placement="bottom-right">
<span class="fa fa-filter"></span>
</button>
<li class="dropdown-filter">
<script type="text/ng-template" id="dropdown-template">
<ul class="dropdown-menu">
<div>
<input type="checkbox" id="disabledStores">
<label for="disabledStores">Show Disabled Stores</label>
</div>
</ul>
</script>
</li>
</div>
我做错了什么?
发布于 2018-02-26 14:38:16
您需要在属性中保存所选内容的值,并使用ng模型绑定到html。
在控制器中必须有:disabledStored : boolean = false.
在你的临时模式中:<input type="checkbox" id="disabledStores" ng-model="disabledStored">
选中复选框时,属性值将为true。
https://stackoverflow.com/questions/48998038
复制