angularjs - How to filter an ng-repeat by clicking on link in repeated template -
i have ng-repeat. want able click link inside of items filter list item. how can accomplished?
<div ng-repeat="item in items"> <a ng-click="?">select one</a> </div>
items have unique ids:
$scope.items = [ {id: 1} {id: 2} ]
you can use filter
, , make sure use $parent
refer selected
model in parent scope since ng-repeat
creates new scope each repeated item.
<div ng-repeat="item in items | filter:selected"> <a ng-click="$parent.selected=item"> select 1 {{item}} </a> </div>
Comments
Post a Comment