2014-07-01 34 views
1

我有一个中继器DIV,可以说如何检索从指定的URL查询字符串参数NG-包括AngularJs

<div ng-repeat =" employee in employees"> 
    <div data-ng-include="'./app/details/employeedetails.html?id=123'"></div> 
//id will change based on employee. 
</div> 

这就需要员工详细信息控制器在员工每个员工。 我需要获取查询字符串参数并检索该员工的详细信息。 如果它在路由中,我可以使用$ location.search(),但这不会导致路由更改。

+1

该路径已为您所知,如果您想要使用模板可用的任何范围变量,您可以始终在您的ng-include中使用ng-init –

回答

1

由于大雁莫雷诺Leon说,你可以使用ngInit初始化本地属性,然后引用您的ngInclude d模板属性:

<!-- 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}} 

还参见本short demo

相关问题