Use ui-router Even if You Aren’t Routing

You should be using ui-router to organize your AngularJS application’s UI, even if you do not expose corresponding URLs. The name ui-router is misleading: its real power is organizing your UI into named, nested, or parallel views. The state concept offers a higher-level alternative to using ng-include and ng-controller, and is more suited to modeling large areas of the UI than custom directives.

Other benefits include:

  • A standard way to collect analytics. By keeping track of visited states, you can see how people use your application. Ad-hoc organizational methods will require an ad-hoc analytics implementation.
  • A standard way to implement common UI features, such as tabs and modals. For complex UIs, consider employing ui-router-extras.
  • A standard way to structure files into folders. Since states group moderately-sized chunks of the UI, having your folder structure mirror the state tree will make the folder structure easy to understand with each folder containing a reasonable number of files.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.