【问题标题】:Unable to select dropdown option more than once无法多次选择下拉选项
【发布时间】:2018-12-28 03:09:07
【问题描述】:

我有一个下拉声,我想检测到所有事件,即使它们是相同的,即使选择自定义时期,显示模态,但我需要用户能够通过他想要的所有次数使用这个模态,即使被选中,这里是代码:

<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 setDateMode() {
    $scope.selection.date.mode === "c" ? clickCustomInput() : dateSelected();
}

【问题讨论】:

    标签: html angularjs select dropdown


    【解决方案1】:

    基本上你应该三思而后行是否真的需要这个。您只能通过为每个选项添加点击指令来实现它:

     <option value="d" ng-show="visible.date.d" ng-click="setDateMode()">Day</option>
    

    这将导致setDateMode() 的两次调用,每个选择除了所选值保持不变。但是您不能从选择元素中删除ng-change(),因为当ng-click() 触发时,下拉列表还不知道当前选择的值...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-10
      • 2016-01-29
      • 2014-06-28
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多