I need to have a url structure in place for hierarchical categories using angularjs ui-router.
Example;
Category tree is like below:
- Root
- -Application 1
- --Category level 1
- ---Category level 2
- ----Category level 3
- -Application 2
- -Application 3
The url xyz.com/application-1/category-1 will display articles in category level 1, similarly xyz.com/application-1/category-1/category-2/category-3 will display articles in category level 3. This can go upto the 4 or 5 levels of categories.
According to my understanding, i will have to define states for each of the category levels and all those states can access the same template and controller. Is there a better, smarter way of implementing these states?
Use stateProvider with nested states and views https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views
I didn't mention named views. you can go through the link and It helps a lot.
But the above makes heavy structuring of states. So, you need to display a relevant info in a single state. For example, if there are three categories, and you want to show in single page then you can define a state like this.
Or you can have a single parent controller for all the views.
now, in html you will have