javascript - Angularjs using ng-if for selective ng-repeat -
i have following arrays:
$scope.selected_items = [ {id: "12345"}, {id: "67890"} ] $scope.list_items = [ { id: "12345", name: "first", more: "data" }, { id: "22222", name: "second", more: "data2" }, { id: "33333", name: "third", more: "data3" }, ]
i trying list out items in $scope.list_items
who's id
not present in $scope.selected_items
. know have ng-if
can't figure out do.
<div ng-repeat="data in list_items" ng-if="????"> {{ data.name }} </div>
could me figure out problem?
i suggest storing information if object selected within array itself.
e.g.:
javascript
$scope.list_items = [ { id: "12345", name: "first", more: "data", selected: true }, { id: "22222", name: "second", more: "data2" }, { id: "33333", name: "third", more: "data3" selected: true }, ]
html
<div ng-repeat="data in list_items | filter:{selected:false}"> {{ data.name }} </div>
Comments
Post a Comment