0

I am working on angular-meteor. I have a collection called grace in the following json format

grace: {
    "mail-template": {
        "new-status": {
            "in-progress": {
                "name": "demo1",
                    "description": "this is demo"
            },
            "pending": {
                "name": "demo2",
                    "description": "this is another demo"
            }
        }
    }
}

Here I am taking in-progress and pending as keys, name and description as values.

I want to list this inside my html using ng-repeat. But I didn't get any output and no errors found.

The code I used is

ng-repeat="(key,value) in demoCtrl.formSettings.grace['mail-template']['new-status']"

demoCtrl is my controller name and formSettings is name of helpers. Can somebody clear my code?

Erazihel
  • 7,295
  • 6
  • 30
  • 53
Aysha Azura
  • 179
  • 1
  • 2
  • 15
  • Why do you need a repeater for this? – Jacob Mar 22 '16 at 10:31
  • I want to list those templates plus the admin need to edit the details if he wishes to. initially the json file didn't have that new_status object. Mail-template object had the key value pairs and this code was working perfect. – Aysha Azura Mar 22 '16 at 10:34
  • You need to debug this, put `{{ key }}` AND `{{ value | json }}` inside the `ngRepeat`. You can anso try and print `{{ demoCtrl.formSettings.grace | json }}` before the `ngReapet` to make sure everything is connected as expected and that you didn't missed anything – Alon Eitan Mar 22 '16 at 10:35

1 Answers1

0

I made this JSFiddle. It seems to work just fine. Make sure that you've got the correct data in the demoCtrl.formSettings.

JS

$scope.obj = {
    grace: {
       "mail-template": {
           "new-status": {
               "in-progress": {
                   "name": "demo1",
                       "description": "this is demo"
               },
               "pending": {
                   "name": "demo2",
                       "description": "this is another demo"
               }
           }
       }
    }
};

HTML

<div ng-repeat="(key,value) in obj.grace['mail-template']['new-status']">
    {{key}}: {{value}}
</div>
Erazihel
  • 7,295
  • 6
  • 30
  • 53
  • sorry to tell my code was working well. Like you said placed the code in a hidden div... Thanks for your effort in helping – Aysha Azura Mar 23 '16 at 03:48