I am trying to understand what this state means in ui-router:
$stateProvider.state('app', {
abstract: true,
url: '/{lang:(?:da|en)}',
template: '<ui-view/>'
});
$stateProvider.state('app.home', {
url: '',
templateUrl: 'views/home-page.html',
});
Specifically what does {lang:(?:da|en)} do. I've not seen this construct before.
This is using what is called Regex Parameters You can see their documentation here
So, /{lang:(?:da|en)}
means to check that the lang
parameter is either da
or en
. If so, then render the template.
Specifically, this will match /da
, or /en