当ng-repeat包含具有变量的动态ng-include时,它不能正确地获取变量。
请参阅此plunker。
主要HTML代码:
<table style>
<tr>
<th>Student</th>
<th>Teacher</th>
</tr>
<tbody ng-repeat="val in data">
<tr>
<td>
<div ng-include src="'profile.html'" onLoad="profile=val.student"></div>
</td>
<td>
<div ng-include src="'profile.html'" onLoad="profile=val.teacher"></div>
</td>
</tr>
</tbody>
</table>
profile.html代码
<span>Id - {{profile.id}}</span>
<span>Name - {{profile.name}}</span>
如果不使用ng-include链接,您可以看到它完美地工作。
P.S. 这是我实际想要实现的原型。 主要问题在于动态ng-include中使用的变量存在于ng-repeat中。
我已经查看了类似以下问题的内容,但没有得到任何答案。