I'm trying to build a route for multiple unique landing pages with the following structure
domain.com/:state/:city/:category
How can I define the route so that the state, city, and category can be only one of predefined values, aka:
state = /ca|ma|ak|az|ar .../i
city = /los-angeles|san-francisco|.../i
category = /painting|plumbing|.../i
These lists are long so having a huge regex doesn't make much sense (or does it?)
Would I use a rule() ? $urlMatcherFactory? how can I use a function?
any help is appreciated. Thanks in advance
The way to go here, is with custom type.
As shown in this Q & A, in case we wan to create some type which is ready to process values true, false, 1, 0 as
boolean
, we can define it like this (there is also working plunker):The same way we can define our types
And later we can use them for any amount of state defintions:
That all could work because we can define url for UrlMatcher like this
So, not only regexp - but also the
type
- including our custom one