[英]Unable to select dropdown option more than once
I have a dropdown and I want to detect all the events, even if they are the same, when custom period is selected a modal is displayed, but I need that the user be able to use this modal all the times he want, even if is selected, here is the code: 我有一个下拉菜单,我想检测所有事件,即使它们相同,选择自定义时间段时也会显示模态,但是我需要用户能够一直使用他希望的模态,即使被选中,下面是代码:
<div class="form-group">
<select width="'100%'" ng-model="selection.date.mode"
class="form-control input-sm" ng-change="setDateMode()">
<option value="d" ng-show="visible.date.d" >Day</option>
<option value="w" ng-show="visible.date.d" >Week</option>
<option value="m" ng-show="visible.date.d" >Month</option>
<option value="y" ng-show="visible.date.d">Year to Date</option>
<option value="c" ng-show="visible.date.d" >Custom</option>
<option value="l" ng-show="visible.date.d" >Last 30 days</option>
</select>
AngularJS function: AngularJS函数:
function setDateMode() {
$scope.selection.date.mode === "c" ? clickCustomInput() : dateSelected();
}
Basically you should think twice whether you really need this. 基本上,您应该三思而后行是否真的需要这个。 You can only achieve it by adding a click-directive to each option:
您只能通过在每个选项中添加点击指令来实现:
<option value="d" ng-show="visible.date.d" ng-click="setDateMode()">Day</option>
This will cause double calls of setDateMode()
with each selection except the selected value stays the same. 这将导致每次选择都重复调用
setDateMode()
,但所选值保持不变。 But you can't remove ng-change()
from the select-element because when ng-click()
fires the dropdown list doesn't know the currently selected value yet... 但是您无法从select元素中删除
ng-change()
,因为当ng-click()
触发时,下拉列表尚不知道当前选择的值...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.