I work with angularjs and UI-Router. I would like to set up routes that set the selected language. although this part of the route should be optional.
I have the following conditions:
{ state: 'app', config: { abstract: true, url: '/{lang:(?:de|en)}', template: '<ui-view/>' } } { state: 'app.mainview', config: { url: '/mainview', templateUrl: 'app/mainview/mainview.html', controller: 'MainviewController', controllerAs: 'vm', title: 'Main View', settings: { pos: 1, displayName: 'Mainview', icon: 'code-array' } } }
now you can only go to mainview with
example.com/en/mainview
Although I would like to configure ui-router so that all o are valid:
example.com/mainview example.com/en/mainview example.com/de/mainview
Is it possible to specify a route with an optional language parameter at the beginning without using a double slash? If not, what alternatives do you offer?
source share