Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  16] [ 3]  / answers: 1 / hits: 51051  / 11 Years ago, wed, june 26, 2013, 12:00:00

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?


More From » angularjs

 Answers
7

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>

[#77387] Tuesday, June 25, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
domeniccolti

Total Points: 276
Total Questions: 98
Total Answers: 93

Location: India
Member since Fri, May 13, 2022
2 Years ago
domeniccolti questions
Mon, Oct 18, 21, 00:00, 3 Years ago
Thu, Oct 14, 21, 00:00, 3 Years ago
Thu, Jul 15, 21, 00:00, 3 Years ago
Sat, Oct 24, 20, 00:00, 4 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
;