Nadav Miller
Nadav Miller

Reputation: 491

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.

Upvotes: 0

Views: 56

Answers (2)

Vasile
Vasile

Reputation: 134

you have an html error there: a link inside a link. Notice that the user.Phone link is inside the already existing link that you use 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>

Upvotes: 0

kasoban
kasoban

Reputation: 2167

You cannot put an <a> tag within an <a> tag. This is against HTML definition.

Try changing your outer <a> tag to a <div> and remove the href attribute.

Upvotes: 2

Related Questions