如何在 angular-table 中添加选择模型复选框

how can i add a slection model checkbox in angular-table

Angular Table 带有输入类型复选框的创建代码。

angular.module("tableApp",[]).controller('tableAppCtrl', ['$scope',
  function($scope) {
    $scope.titleString="Table Demo";
    $scope.prodDataTable = [{
      "productType": "A",
      "productName": "Aaaaaa"
    }, {
      "productType": "B",
      "productName": "Bbbbbb"
    }, {
      "productType": "C",
      "productName": "Cccccc"
    }];
  }
]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div  ng-app="tableApp" ng-controller="tableAppCtrl">
  <h3>{{titleString}}</h3>
<table>
  <tr>
    <th><input type="button" value="checkALL"></th>
    <th>Product Type</th>
 <th>Product Name</th>

  </tr>

  <tr ng-repeat="d in prodDataTable">
    <td><input type="checkbox"></td>
    <td>{{d.productType}}</td> 
    <td>{{d.productName}}</td>
  </tr>


</table>
  </div>

我一直在使用angular-table,我必须在其中包含一个选择模型。

请提出与 table 一起使用的方法或链接。

试试下面的代码 -

angular.module("tableApp",[]).controller('tableAppCtrl', ['$scope',
 function($scope) {
  $scope.titleString="Table Demo";
  $scope.selectAllval= false;
  $scope.selectAll= function(val){
 if(val==false){
  $scope.selectAllval= true;
 } else{
  $scope.selectAllval= false;
 }
  };
  $scope.prodDataTable = [{
  "productType": "A",
  "productName": "Aaaaaa"
  }, {
  "productType": "B",
  "productName": "Bbbbbb"
  }, {
  "productType": "C",
  "productName": "Cccccc"
  }];
 }
]);
  

  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    <div  ng-app="tableApp" ng-controller="tableAppCtrl">
  <h3>{{titleString}}</h3>
 <table>
   <tr>
     <th><input type="button" value="{{(selectAllval==true) ? 'UncheckALL' : 'checkALL'}}" ng-click="selectAll(selectAllval)"></th>
     <th>Product Type</th>
  <th>Product Name</th>

   </tr>

   <tr ng-repeat="d in prodDataTable">
     <td><input type="checkbox" ng-checked="selectAllval" ></td>
     <td>{{d.productType}}</td> 
     <td>{{d.productName}}</td>
   </tr>


 </table>
  </div>

使用这个,但你需要处理重复值的创建-

<div  ng-app="tableApp" ng-controller="tableAppCtrl">
<h3>{{titleString}}</h3>
<table>
  <tr>
    <th><input type="button" value="{{(selectAllval==true) ? 'UncheckALL' : 'checkALL'}}" ng-click="selectAll(selectAllval)"></th>
    <th>Product Type</th>
 <th>Product Name</th>

  </tr>

  <tr ng-repeat="d in prodDataTable">
    <td><input type="checkbox" ng-checked="selectAllval" ng-click="setProductType(d.productType)"></td>
    <td>{{d.productType}}</td> 
    <td>{{d.productName}}</td>
  </tr>


</table>

{{setProductTypes}}

angular.module("tableApp",[]).controller('tableAppCtrl', ['$scope', function($scope) { 
    $scope.titleString="Table Demo"; 
    $scope.selectAllval= false; 
    $scope.setProductTypes= []; 
    $scope.selectAll= function(val){ 
        if(val==false){ 
            $scope.selectAllval= true; 
        } else{ 
            $scope.selectAllval= false; 
        } 
    }; 
    $scope.setProductType= function(type){ 
        $scope.setProductTypes.push(type); 
    }; 
    $scope.prodDataTable = [{ "productType": "A", "productName": "Aaaaaa" }, { "productType": "B", "productName": "Bbbbbb" }, { "productType": "C", "productName": "Cccccc" }]; } ]);