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,135
  • 7
  • 31
  • 44

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,182
  • 1
  • 21
  • 43
0

try this

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