1

I am developing an Android application using angularjs and ionic framework, using JSON to display some data in the application front end. I want to generate HTML like this:

<span>name1</span>
<span>name2</span>
<span>name3</span>

Here is my JSON:

var items=[
        {name:["name1","name2","name3"]}        
    ];

I can read the JSON node by myJsonObject.name, but how can I iterate through the nested array?

8
  • Take a look at the official documentation of ng-repeat Commented Oct 19, 2014 at 3:45
  • i will tried ,but cant get the answer Commented Oct 19, 2014 at 3:48
  • There are examples in the documentation link. Commented Oct 19, 2014 at 3:48
  • Thats not help in my case Commented Oct 19, 2014 at 3:52
  • you need try something.. Show us what have you tried and what issue you faced? Commented Oct 19, 2014 at 3:54

2 Answers 2

3

To iterate over the nested array you would have to do something like the following:

<span ng-repeat="name in myJsonObject.name">{{name}}</span>
Sign up to request clarification or add additional context in comments.

Comments

0
  • set value in angularjs $scope.items=[ {name:["name1","name2","name3"]} ];

  • iterate in markup

    <span ng-repeat="name in items.0.name">{{ name }}</span>
    

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.