2

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.

1
  • 1
    the path is already known to you and you can always use ng-init in your ng-include if you want to et any scope variable available to the template Commented Jul 1, 2014 at 18:42

1 Answer 1

1

As Dayan Moreno Leon said, you can use ngInit to initialize a local property and then reference that property in your ngIncluded 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.