0

I am building a mobile app with Ionic and AngularJS. I have a scenario like this:

A Category has got a number of sub categories.

Example given: If you click on any category it shows its sub categories. If you click on any sub category it shows its sub categories and so on.

I tried with changing url by passing parameters but that didn't work. What is the best approach to achieve this? Thanks in advance.

MHX
  • 1,581
  • 2
  • 21
  • 31
user1175121
  • 123
  • 1
  • 1
  • 8

1 Answers1

0

It sounds to me like you might need to create new states dynamically based on the number of subcategories that exist. I'd check out this SO question about creating states dynamically.

When you fetch all of the subcategories, execute a function to calculate the states based on the number of subcategories.

Edit to add: After you have the states, then you should be able to easily navigate to the child states using a <ui-sref> tag. ui-sref

Community
  • 1
  • 1
Jack Collins
  • 1,145
  • 10
  • 21
  • But every time you load the same state dynamically the controller will be get executed which is not required in my case. – user1175121 Dec 07 '15 at 11:14