Reputation: 1371
I have a repeater div, lets say
<div ng-repeat =" employee in employees">
<div data-ng-include="'./app/details/employeedetails.html?id=123'"></div>
//id will change based on employee.
</div>
This would call employee details controller for each employee in the employees. I need to get the query string parameters and retrieve the details for that employee. If it is in route then I can use $location.search() but this doesn't cause a route change.
Upvotes: 2
Views: 1011
Reputation: 48211
As Dayan Moreno Leon said, you can use ngInit
to initialize a local property and then reference that property in your ngInclude
d template:
<!-- The VIEW -->
<div ng-repeat="employee in employees" ng-init="id=employee.id">
<div ng-include="'app/details/employeedetails.html'"></div>
</div>
<!-- The TEMPLATE -->
Employee ID: {{id}}
See, also, this short demo.
Upvotes: 1