Reputation: 26317
Using ng-repeat, how would I loop through the following:
var messages : [
{text:"Standard Message"},
{text:"Success Message!", type:"success"},
{text:"Alert Message!", type : "alert"},
{text:"secondary message...", type : "secondary"}
]
I've tried:
<p ng-repeat="message in messages">{{message}}</p>
and it doesn't seem to work, how would I do this?
Upvotes: 26
Views: 52036
Reputation: 17100
You need to insert your messages array into the $scope:
$scope.messages = [
{text:"Standard Message"},
{text:"Success Message!", type:"success"},
{text:"Alert Message!", type : "alert"},
{text:"secondary message...", type : "secondary"}
]
and then use it as following:
<p ng-repeat="message in messages">{{message.text}}</p>
Upvotes: 38