Reputation: 403
I need to filter some data according to the value I get from ng-repeate.
my html looks like this.
I need to display the data from other scope object($scope.allData
) by filtering using the value
<div ng-repeat="value in selectedIds">
<h6>Id</h6>{{}} <br/>
<h6>Name</h6>{{}} <br/>
<h6>Age</h6>{{}} <br/>
</div>
and my controller look like
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.selectedIds=[{id:"123"},{id:"124"},{id:"125"},{id:"126"}];
$scope.allData=[{id:"123",name:"James",age:"21"},
{id:"124",name:"James",age:"21"},
{id:"125",name:"Frank",age:"22"},
{id:"126",name:"John",age:"24"},
{id:"127",name:"Jimmy",age:"26"},
{id:"128",name:"Ann",age:"61"},
{id:"129",name:"Mark",age:"41"},
{id:"130",name:"Lach",age:"33"}
];
});
Upvotes: 0
Views: 140
Reputation: 4370
you can use filter
in your ng-repeat function.
<body ng-controller="MainCtrl">
<div ng-repeat="value in selectedIds">
<div ng-repeat="values in allData | filter: value.id">
<h6>Id</h6>{{values.id}} <br/>
<h6>Name</h6>{{values.name}} <br/>
<h6>Age</h6>{{values.age}} <br/>
</div>
</div>
</body>
Hope it works in your case. here is the working link
Upvotes: 1