Reputation: 3400
I am building a large, complex AngularJS application (think ERP system). I am having a hard time deciding when it is appropriate to use ui-view
, ng-include
or a custom directive + templateURL
.
I will give a few concrete examples to give y'all something to work with.
What are the best practices?
Upvotes: 18
Views: 3627
Reputation: 52867
For any large or complex application, I would suggest organizing as much of your code into re-usable custom directives as possible. Custom directives will allow you to leverage angular directives for maximum re-usability and minimize the repetitive HTML that exists when you rely only on built-in directives.
UI views are appropriate for swapping out controllers and views dynamically depending on the route. If you have application functionality where each view and controller combination is self-contained, then using a ui-view with routes makes sense.
Upvotes: 11