Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an array($rootScope.language); of objects that look like this:

[{name: "Oskar", lastname: "Doe"},{name: "John", lastname: "Steward"}]

I want to loop through all of them in my template. I tried this:

    <div ng-repeat="entry in language"> 
       <p>{{name}} {{lastname}}</p>
    </div>

This outputs nothing and I don't get any errors. What am I missing?

share|improve this question
    
Do you need to use $rootScope? Generally you don't want to put things there since it can be used like a global variable. –  Loc Nguyen Feb 26 '14 at 13:47

2 Answers 2

up vote 3 down vote accepted

There is no name or lastname directly on the scope, so you have to refer every ng-repeat item by an alias - in your case entry

That's why you have to use

<div ng-repeat="entry in language"> 
   <p>{{entry.name}} {{entry.lastname}}</p>
</div>
share|improve this answer

I needed to add entry to the variables like this:

{{entry.name}}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.