I tried to answer a similar one (if not one):
Angular js - route-ui add default cart
There is a working plunker , solving the problem for language , and not for city (but the concept is the same)
so we must / must introduce some super-standing "root".
In our case, we can even use some regular expression to limit the allowed values โโ- because it would be difficult to guess what city is and what events
.state('root', { url: '/{city:(?:Prague|Bristol|Denver)}', abstract: true, template: '<div ui-view=""></div>', params: {lang : { squash : true, value: 'Prague' }} })
It is important to install params : {} . It says that the default is Prague, so it will be a city if none are selected. It is also important - it must be crushed, skipped, if there is a match with the value of the "Prague" parameter :
params: {lang : { squash : true, value: 'Prague' }}
Now we can enter some nested state (s) that would declare root as the parent:
.state('events',{ parent: 'root', url: '/events/:id' ... })
Check out the working example (with language instead of city) here . See Original Q and A for more details.
source share