I have ng-repeat
ed data, and am trying to get only the ones the user has selected. I\'m not sure how to do it though, this is what I have:
HTML:
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 ];
});
};
});
-
{{record.Id}}
Show Selected
http://plnkr.co/edit/lqtDQ6
You can store the flag in separately and use it to filter the data.