Note that there are some explanatory texts on larger screens.

plurals
  1. POLooping through deep objects in ng-repeat
    primarykey
    data
    text
    <p>I'm in angular and i have a object like this.</p> <pre><code>var items = [{ title: 'Something', children: [ { title: 'Hello World' }, { title: 'Hello Overflow' }, { title: 'John Doe', children: [ { title: 'Amazing title' }, { title: 'Google it' }, { title: 'I'm a child', children: [ { title: 'Another ' }, { title: 'He\'s my brother' }, { title: 'She\'s my mother.', children: [ {title: 'You never know if I'm going to have children'} ]} ]} ]} ] }]; </code></pre> <p>I wan't to loop through all of these so i have something like this.</p> <blockquote> <p>&nbsp;&nbsp;&nbsp;&nbsp;• Something</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; • Hello World</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; • Hello Overflow</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; • John Doe</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• Amazing Title </p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• Google it</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• I'm a child</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• Another </p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• He's my brother</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• She's my mother</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;• You never know if I'm going to have children</p> </blockquote> <p>The problem is I wouldn't know how deep this object will go or what's in it. so I wouldn't be able to do it manually. I have done a basic loop with <code>ng-repeat</code> in the fiddle provided at the bottom, but i can't figure out how I can automatically loop through these and create nested <code>&lt;ul&gt;</code>'s and <code>&lt;li&gt;</code>'s. </p> <p>What would be the best way to accomplish this?</p> <p><strong>Demo: <a href="http://jsfiddle.net/XtgLM/" rel="nofollow">http://jsfiddle.net/XtgLM/</a></strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload