0

Sorry for the title, this is my first post.

OK, my problem is, I have this JSON:

   {
  "nodes" : [
    {
      "node" : {
        "Title" : "this is a title",
        "slideshowImage" : [
          {
            "src" : "imagen.png",
            "alt" : ""
          },
          {
            "src" : "imagen.png",
            "alt" : ""
          },
          {
            "src" : "imagen.png",
            "alt" : ""
          },
          {
            "src" : "imagen.png",
            "alt" : ""
          }
        ],
        "Thumbnail" : {
          "src" : "imagen.png",
          "alt" : ""
        },
        "id" : "28"
      }
    }
  ]
}

How can I get a ng-repeat to slideshowImage

Ex: ng-repeat="node in items.slideshowImage"

{{node.node.slideshowImage.src}}

Am I doing it wrong?

1
  • You should do ng-repeat="item in nodes.node.slideshowImage" and {{ item.src }} Commented Mar 5, 2016 at 13:54

3 Answers 3

2

Make sure your object is assigned to nodes object, then it would be simple like below.

ng-repeat="image in nodes.node.slideshowImage"
Sign up to request clarification or add additional context in comments.

1 Comment

@JulianChabrillon click on tick icon below upvote button, so that this answer get accepted. Thanks :-)
1

If you wanna ng-repeat in view Directly Like following :-

      <div ng-repeat="N1 in sampleData.nodes"> 
          <div ng-repeat="N2 in N1.node.slideshowImage">
                 {{N2.src}}
           </div>
      </div> <!-- Looped down to Subnodes For your Understanding --!>

Or Just Save it in to a scope Quick way :-

$scope.quickData=$scope.sampleData.nodes[0].node.slideshowImage; // as per data length

Now Roll it (ng-repeat) :-

     <div ng-repeat="quick in quickData">
               {{quick.src}}
         </div>

https://plnkr.co/edit/EhuLmjzNa5srX2AV2gqT?p=preview

Both results are saved in Plunker

Happy Learning !!

6 Comments

doesn't make sense repeating the properties in node object. You have one too many nested repeats
showed diff ways to loop it of course one of it bit lengthy way,Just for beginner understanding purposes and For some JSON Iterate Experience
Still doesn't make sense. Just loop over array N1.node.slideshowImage.
@ charlietfl yes that is precise .. updated :-) as a beginner her can experiment and undestand himself for a quicker solution ..
|
0

You should do

ng-repeat="item in nodes.node.slideshowImage"

and in your views

{{ item.src }}

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.