【问题标题】:bentorf's angular bootstrap multiselect: clearing selections on clickBentorf 的角度引导多选:单击时清除选择
【发布时间】:2019-11-11 15:02:12
【问题描述】:

我们在一个有几个其他字段的表单上使用betorf's angular bootstrap multiselect。在表单的底部,我们有一个“重置”复选框,我们希望在为真时清除表单。我们如何通过这种多选实现这一点?我们当前的代码如下所示:

<multiselect classes-btn="'btn-primary btn-block'" 
             placeholder="Choose your users"
             show-tooltip="true"
             show-search="true" 
             show-select-all="true" 
             show-unselect-all="true" 
             ng-model="c.selection" 
             options="data.users" 
             show-search="true" 
             id-prop="id" 
             display-prop="name">
</multiselect>
$scope.$watch(function () {  
    return c.selection;
}, function () {  
    var arr = [];
    console.log(c.selection);
    console.log(c.selection[0].id);
    for(var i =0; i<c.selection.length; i++) {
        arr.push(
            c.selection[i].id
        );
    }
    var users = arr.toString();
    $scope.page.g_form.setValue('u_slush_test',users);

    if($scope.page.g_form.getValue('clear_form')==true){
        c.selection=[];
    }
});  

【问题讨论】:

    标签: angularjs twitter-bootstrap multi-select


    【解决方案1】:

    我们有一个“重置”复选框,我们希望在为真时清除表单

    我建议应用使用重置按钮而不是重置复选框:

    <button ng-click="reset()">Reset</button>
    
    $scope.reset = function() {
         $scope.c.selection = null;
    }; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 2011-02-10
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-22
      相关资源
      最近更新 更多