zoukankan      html  css  js  c++  java
  • Angularjs:实现全选

    html:

    <div class="input-group">
      <span class="input-group-addon" style="background-color: #fff;border:none">状态</span>
      <div ng-model="queryParam.status" class="ui-checkbox ui-checkbox-primary" style="margin-top: 4px;margin-bottom: 0;">
        <label class="ui-checkbox-inline">
          <input type="checkbox" ng-model="all" ng-change="selectAll()">
            <span>全部</span>
        </label>
        <label class="ui-checkbox-inline" ng-repeat = "x in List">
          <input type="checkbox" ng-model="x.checked" ng-change="selectOne()">
          <span>{{x.name}}</span>
        </label>
      </div> </div>

    js:

    $scope.checked = [];
    $scope.selectAll = function () {
      if($scope.all) {
        $scope.checked = [];
        angular.forEach($scope.List, function (i) {
          i.checked = true;
          $scope.checked.push(i.value);
        })
      }else {
        angular.forEach($scope.List, function (i) {
          i.checked = false;
          $scope.checked = [];
        })
      }
    };
    
    $scope.selectOne = function () {
      angular.forEach($scope.List , function (i) {
        var index = $scope.checked.indexOf(i.value);
        if(i.checked && index === -1) {
          $scope.checked.push(i.value);
        } else if (!i.checked && index !== -1){
          $scope.checked.splice(index, 1);
        };
      })
      if ($scope.List.length === $scope.checked.length) {
        $scope.all = true;
      } else {
        $scope.all = false;
      }
    };
  • 相关阅读:
    vi编辑器常用配置
    vi编辑器使用
    Windows进程通信 -- 共享内存
    Loadrunner关于页面检查的几个函数详解
    使用Loadrunner进行文件的上传和下载
    LR学习笔记之—参数和变量
    LoadRunner字符串处理
    在LoadRunner中查找和替换字符串
    为LoadRunner写一个lr_save_float函数
    LoadRunner中调用SHA1算法加密字符串
  • 原文地址:https://www.cnblogs.com/koto/p/6290049.html
Copyright © 2011-2022 走看看