René Thomassen René Thomassen - 5 days ago 4
AngularJS Question

How to use AngularJS ng-repeat on <ul> tag without repeating it?

With this code:

<ul data-ng-repeat="airport in airports">
<li>{{airport.code}}</li>
<li>{{airport.city}}</li>
<li>{{airport.name}}</li>
</ul>


I end up with three
<ul>
, each with one
<li>
inside of them.

How can I get one
<ul>
with three
<li>
inside?

Answer

You can use ng-repeat-start directive:

<ul>
    <li ng-repeat-start="airport in airports">{{airport.code}}</li>
    <li>{{airport.city}}</li>
    <li ng-repeat-end>{{airport.name}}</li>
</ul>

Here it is working in plnkr.

Comments