2015-03-18 85 views
-1

我已經在我的JavaScript稱爲數組 「動物」 名單:顯示陣列中的角

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

我的HTML是:

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

目前,它顯示的是,像這樣:

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

我希望它能像這樣顯示:

dog 
cat 
horse 
cow 

我已經看過ng-list指令的官方Angular文檔,但我仍在撓頭。有沒有可能是另一個(更好的)指示呢?

建議表示讚賞。

回答

7

使用NG-重複:

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

<ul> 
    <li ng-repeat="animal in animals">{{animal}}</li> 
</ul> 
+0

謝謝;比我想要做的更簡單。它現在有效。 – user3159063 2015-03-18 21:07:03

+0

很高興能有所幫助。如果能解決您的問題,您可以將其標記爲答案嗎? – nweg 2015-03-18 21:16:14