0

Newby AngularJS design question. When I say "controller" I am referring to all the usual components too, like directives, templates, and other things that usually go together.

Need to create a user "workspace" with folders and objects in each folder. Users can create/delete/rename folders and their child objects. There could be maybe 50 folders max but maybe 100 objects in each folder.

Naturally I want to implement a recursive controllers idea like mentioned for this question Is it possible to make a Tree View with Angular?

  • Would there be a performance issue with a recursive controller setup or would it be better to use one controller for the whole tree?
    • What is some good sample code using a single tree controller setup?
  • In general, does AngularJS handle recursive patterns well or is it an anti-pattern for ng?
Community
  • 1
  • 1
AlJo
  • 161
  • 1
  • 13
  • Maybe look at using Kendo UI Tree View. Kendo have decent Angular bindings and its better than writing it from scratch IMO. Heres an example... http://demos.telerik.com/kendo-ui/treeview/angular – hally9k Sep 26 '15 at 05:25
  • Recursive templates can be done with: https://github.com/dotJEM/angular-tree – Jens Oct 27 '15 at 11:56

1 Answers1

2

I would recommend and use https://github.com/angular-ui-tree/angular-ui-tree It has a ton of existing functionality for insertion, drag and drop, clone... It is very flexible, a few great demos, and has a lot of history and contributors.

With this you would use 1 controller and and a single directive and hold all the elements in 1 json object.

Also it is Open Source / Free whereas Kendo UI is $699

Enkode
  • 4,515
  • 4
  • 35
  • 50
  • Although you don't answer my questions, I do appreciate the link. – AlJo Sep 26 '15 at 18:05
  • I gave you a recursive data solution with single controller. This discusses the recursive controller option http://stackoverflow.com/questions/18415142/how-to-handle-recursive-rendering-of-data-using-angularjs. I would not take that route when the simplest way to is to use recursive data and if you need addional directives or controllers within each tree node you can do so. – Enkode Sep 26 '15 at 23:21
  • I know I have both options. The question is about pros and cons. – AlJo Sep 27 '15 at 17:59