I'm using the 1.x version of UI-Router. I have a site that is broken up by location, each location has identical layouts and content for its pages:
mysite.com
mysite.com/location1
mysite.com/location1/about
mysite.com/location1/contact
mysite.com/location2
mysite.com/location2/about
mysite.com/location2/contact
I'd like to use the same templates/components for the pages (about, contact) etc, but change the API queries I make based on the parameter. I'm setting up my states with a location URL parameter like so:
.state('about', {
url: '/:location/about',
params: {
location: 'default'
}
})
What I'd really like to be able to do is instead of providing some sort of default location parameter, I'd like it to be completely optional - as in the following urls would work:
mysite.com/about
mysite.com/contact
And it would provide the default (but not show in the URL). I'd like the other directives like ui-sref
to work the same way. I should be able to use:
ui-sref="about({location: something})"
and if something
was null or falsy it would show the shortened url. Other directives like ui-sref-active
should be smart enough to recognize the defaults as well.
Something like that possible? Thanks in advance!