1

Im trying to run ng-repeat on this obj to display "settings":

var settingsTest = {
            "id": "2",
            "active": "1",
            "settings": {
                "action":0,
                "somestaff":0,
                "message":0,
                "mouth":0,
                "heost":0,
                "gaming":0,
                "live.live":0,
                "notifications": 0,
                "profile": 0
            }
        };

And here is HTML to display it:

<ul>
   <li ng-repeat="(name, value) in settingsTest['settings'] | orderBy: 'name'">
   </li>
</ul>

At the end it gives me an error that the message has to be a string.

Alex Pan
  • 4,341
  • 8
  • 34
  • 45

2 Answers2

3

First, make sure your settingsTest is on the $scope or controller -- as you have it, var settingsTest = [...], the view is not going to know about it.

$scope.settingsTest = {
   ...
}

Then, in your view:

<li ng-repeat="(setting, value) in settingsTest.settings">
  {{setting}} {{value}}
</li>

See jsBin

Tom
  • 7,640
  • 1
  • 23
  • 47
0

try this

<li ng-repeat="(settings, value) in settingsTest.settings">{{settings}} {{value}}</li>
Josh Stevens
  • 3,943
  • 1
  • 15
  • 22