ImNotMike ImNotMike - 11 months ago 43
AngularJS Question

How do I list two elements per item in array?

I have several email addresses per user, and I want to give two options per each of those addresses; one is to send email directly, and another one is to send a message via a web form. But how do I enlist two

elements under a single

If I do:

<span ng-repeat="email in User.emails">
<li><a ng-attr-href="mailto:{{ email }}">Email {{ email }}</a></li>
<li><a ng-href="#/SendMessage?email={{ email }}">Send message to {{ email }}</a></li>

Then I'm breaking the HTML structure and semantics.

If I do:

<li ng-repeat="email in User.emails"><a ng-attr-href="mailto:{{ email }}">Email {{ email }}</a></li>
<li ng-repeat="email in User.emails"><a ng-href="#/SendMessage?email={{ email }}">Send message to {{ email }}</a></li>

Then the emails are not in order (because the preferred order is to give primary email address first).

So the ideal output, assuming your email addresses are
(excluding the
just to make reading more clear), would be:

<li><a href="...">Email</a></li>
<li><a href="...">Send message to</a></li>
<li><a href="...">Email</a></li>
<li><a href="...">Send message to</a></li>

How do I do this, without adding disallowed elements into a

Answer Source

If you want to keep the structure the same you can use ng-repeat-start and ng-repeat-end. Check out and look for the Special repeat start and end points section