1

I have an array in my javascript called "animals":

var animals = ["dog", "cat", "horse", "cow"];

My html is:

<p>{{animals}}</p>

Currently it is displaying like so:

["dog", "cat", "horse", "cow"]

I'd like it to display like so:

dog
cat
horse
cow

I've looked at the official Angular documentation for the ng-list directive and am still scratching my head. Is there perhaps another (better) directive for this?

Advice is appreciated.

1 Answer 1

10

Use ng-repeat:

<p ng-repeat="animal in animals">{{animal}}</p>

or

<ul>
    <li ng-repeat="animal in animals">{{animal}}</li>
</ul>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you; much simpler than what I was contemplating doing. It works now.
Glad to be of help. Can you mark this as the answer if it solved your problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.