I'm new to Angular.JS and trying to figure out how to properly implement ng-repeat.
I have a data object in my scope that was formed from JSON from my database. One of the returned 'fields' can sometimes either be just a single string, or an array.
Example:
Email Address = "[email protected]" or
Email Address = ["[email protected]", "[email protected]", "[email protected]"]
I would simply like to display in a series of spans whatever Email Address would contain. So far, I've done this:
<span ng-repeat="EMAIL_ADDRESS in data.EMAIL_ADDRESS">
<span>{{EMAIL_ADDRESS}}</span><br />
</span
For the Email Address that's an array of 3, I get this (which I want):
<span>[email protected]</span><br />
<span>[email protected]</span><br />
<span>[email protected]</span><br />
For the Email Address that's just a string I get:
<span>m</span><br />
<span>e</span><br />
<span>@</span><br />
<span>t</span><br />
<span>e</span><br />
<span>s</span><br />
<span>t</span><br />
<span>.</span><br />
<span>c</span><br />
<span>o</span><br />
<span>m</span><br />
How can I prevent the later situation? I know this is more Javascript behavior, but I'm not sure how to put it in Angular.