1

How to group routes in ui-router?

For example, i have following routes in my app

#/products/p1
#/products/p2
#/products/p3

One way of defining states will be,

.state(‘products.p1’)
.state(‘products.p2’)
.state(‘products.p3’)

But i am looking for something like followings, Is it possible to do so?

.state(‘products’,{
  ‘p1’ : {},
  ‘p2’ : {},
  ‘p3’ : {} 
})
APPLEMAN
  • 13
  • 2

1 Answers1

1

This should be managed by parameters

#/products/p1 // parameter p with value p1
#/products/p2 // still parameter p with value p2
#/products/p3 // value is p3

state can have it defined like this

.state('products', {
    url: "/products/:p
    ...
})
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • Is't possible to assign different controllers based on :P value? I have few static pages and i want to group them under single brach?? – APPLEMAN Oct 19 '16 at 13:47
  • Yes... it is possible, but .. won't be better to have the same controller and different stuff in services? anyhow, here you can see how to do that http://stackoverflow.com/a/27466890/1679310 or http://stackoverflow.com/q/30259668/1679310 – Radim Köhler Oct 19 '16 at 13:50