1

I have a problem writing proper ng-repeat for this object. I would like to display all object properties. There is a main array of apps, each app can have a multiple versions and each version can have multiple users.

Here is object json.

"Awesome App 1": {
    "1.16": {
      "Steve": [
        "[email protected]",
        null
      ],
      "Mike": [
        "[email protected]",
        null
      ]
    }
  },
  "Awesome App 2": {
    "1.7.0": {
      "steve": [
        "[email protected]",
        null
      ]
    }
  }, 

...

Problem is that keys are dynamic and I don`t know how to map it in ng-repeat. Thanks for a help.

4
  • What do you want to do with the null value in the array? Commented Nov 30, 2018 at 19:47
  • Please give an example of the output you are expecting Commented Nov 30, 2018 at 19:47
  • 2
    do you mean something like this: plnkr.co/edit/3wMdzrtkpShLgl8mu9sN Commented Nov 30, 2018 at 20:00
  • @RameezRaja yes, your solution works! Please add it as an answer. Commented Dec 3, 2018 at 13:33

1 Answer 1

2

You can try something like this:

https://plnkr.co/edit/3wMdzrtkpShLgl8mu9sN

$scope.data.json = {"Awesome App 1":
......
};

    <ul>
       <li ng-repeat="(key, val) in data.json">
          App Name: {{key}} <br/>  
          <span ng-repeat="(key2, val2) in val">
             Version: {{key2}} <br/>
             <span ng-repeat="(key3, val3) in val2">
               User: {{key3}} - {{val3[0]}} <br/>
             </span>
          </span>
       </li>
   </ul>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.