In my Angular app, I want to filter the items generated on a dropdown button with ng-repeat based on a list of IDs that I already generate dynamically.
This list is basically an array of numbers that gets updated dynamically with $scope.$watchCollection, e.g.:
$scope.selectedBPs = [1, 2]
Each item I generate with ng-repeat on the aforementioned dropdwon button has an id property. What I want the filter to do, is to only show a specific item if $scope.selectedBPs contains its id.
Currently my HTML is:
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li ng-repeat="marker in vm.markers" ng-click="progressMarkerSelected.name = marker.name;">
<a href role="menuitem" tabindex="-1">{{marker.name}}</a>
</li>
</ul>
So basically, I only want the marker to appear if $scope.selectedBPs.indexOf(marker.bpId) > -1 (bpId being the item's id).
Is it possible to do this with a filter?
How do I pass $scope.selectedBPs to an angular filter, so that the dropdown list also gets updated dynamically whenever the list changes?