0

I have a json file that I'm getting with

$scope.load = function() {
        var httpRequest = $http.get('json/properties.json')
            .then(function(res) {
                $scope.properties = res.data;
            });
    };

The Json file is something like:

        [{
        "property": "address",
        "options": ["zipCode", "city", "cityPrefix", "citySuffix", "streetName", "streetAddress", "streetSuffix", "streetPrefix", "secondaryAddress", "county", "country", "countryCode", "state", "stateAbbr", "latitude", "longitude"]
    }, {
        "property": "commerce",
        "options": ["color", "department", "productName", "price", "productAdjective", "productMaterial", "product"]
    }, {
        "property": "company",
        "options": ["suffixes", "companyName", "companySuffix", "catchPhrase", "bs", "catchPhraseAdjective", "catchPhraseDescriptor", "catchPhraseNoun", "bsAdjective", "bsBuzz", "bsNoun"]
    }]

and I have this HTML:

<div ng-repeat="(property, options) in properties ">
  <p>{{property}} - {{options}}</p>
</div>

For each entry in my JSON array, I want to create a list with the "property" value and inside this list an li with each "option" of this property but for some reason the closest I got to was having 15 (?) lists for each property. Any help?
[EDIT]
Link to current github repository

2 Answers 2

2

Right from the AngularJS ng-repeat duplicate error docs:

<div ng-repeat="(property, options) in properties track by $index">
   <p>{{property}} - {{options}}</p>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Didn't work, I added the github repository, maybe I'm not explaining my problem very well, or maybe my problem is not is this part of the project
0

I think using track by $index will work.

<div ng-repeat="(property, options) in properties track by $index">
          <p>{{property}} - </p>
          <ul>
             <li ng-repeat="option in options track by $index">{{option}}</li>
          </ul>
        </div>

1 Comment

Didn't work, I added the github repository, maybe I'm not explaining my problem very well, or maybe my problem is not is this part of the project

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.