2017-01-23 56 views
-1

視盤強大的文本從選擇複選框值:如何讓angularjs

當我使用JSON數據點擊右側顯示覆選框表基於ID的列名

+0

你能解釋一下嗎? –

+1

請發佈您的代碼並清楚說明您希望它做什麼。 –

回答

0

JS

var app = angular.module('plunker', ['ui']); 

app.controller('MyCtrl', function($scope) { 
    $scope.records = [ { "Id": 1 }, { "Id": 2 }, { "Id": 3 } ]; 
    $scope.selected = {}; 
    $scope.ShowSelected = function() { 
     $scope.records = $.grep($scope.records, function(record) { 
     return $scope.selected[ record.Id ]; 
     }); 
    };  
}); 

HTML

<div data-ng-controller="MyCtrl"> 
     <ul> 
      <li data-ng-repeat="record in records"> 
       <input type="checkbox" ng-model="selected[record.Id]"> {{record.Id}} 
      </li> 
     </ul> 
     <a href="javascript:;" data-ng-click="ShowSelected()">Show Selected</a> 
    </div> 
+0

謝謝Hiren,但面臨幾個問題可以共享plnkr鏈接 – Ashok

相關問題