1

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?

1
  • Do you need to use $rootScope? Generally you don't want to put things there since it can be used like a global variable.CommentedFeb 26, 2014 at 13:47

2 Answers 2

4

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> 
    0

    I needed to add entry to the variables like this:

    {{entry.name}} 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.