Jon Abrams Jon Abrams - 18 days ago 5
AngularJS Question

Is it possible to make a Tree View with Angular?

I'm looking to display data in a tree structure in a web app. I was hoping to use Angular for this task.

Looks like ng-repeat will allow me to iterate through a list of nodes, but how can I then do nesting when a given node's depth increases?

I tried the following code, but the auto-escaping of the HTML is preventing this from working. Plus, the end ul tag is in the wrong place.

I'm pretty sure that I'm going about this problem entirely the wrong way.

Any ideas?

Answer

Have a look at this fiddle http://jsfiddle.net/brendanowen/uXbn6/8/

This should give you a good idea of how to display a tree like structure using angular. It is kind of using recursion in html!