[英]Binding doesn't work in nested elements inside ng-repeat
I have this code: 我有这个代码:
<div class="list-group">
<a href="#" class="list-group-item" ng-repeat="user in users">
<h4 class="list-group-item-heading">{{user.FirstName}} {{user.FirstName}}</h4>
<p class="list-group-item-text">
<a href="#">{{user.Phone}}</a>
</p>
</a>
If I use {{user.Phone}} not inside the <a>
it works, otherwise it displays nothing and I don't get any error or anything. 如果我使用{{user.Phone}}不在<a>
内部,它会工作,否则它什么都不显示,我没有任何错误或任何错误。
You cannot put an <a>
tag within an <a>
tag. 您不能在<a>
标记中放置<a>
标记。 This is against HTML definition. 这是针对HTML定义的。
Try changing your outer <a>
tag to a <div>
and remove the href attribute. 尝试将外部<a>
标记更改为<div>
并删除href属性。
you have an html error there: a link inside a link. 你有一个HTML错误:链接内的链接。 Notice that the user.Phone link is inside the already existing link that you use ng-repeat on: 请注意,user.Phone链接位于您使用ng-repeat on的现有链接中:
I would change code to this: 我会将代码更改为:
<div href="#" class="list-group-item" ng-repeat="user in users">
<h4 class="list-group-item-heading">{{user.FirstName}} {{user.FirstName}}</h4>
<p class="list-group-item-text"><a href="#">{{user.Phone}}</a></p>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.