ui-router's version 0.2.11 introduced option to turn off strict URL matching , but I can't figure out how to actually use it.
I've tried standard config as they use in tests :
app.config(function ($urlMatcherFactoryProvider) {
$urlMatcherFactoryProvider.caseInsensitive(true);
$urlMatcherFactoryProvider.strictMode(false);
});
None of those settings work, so I guess I'm either doing something wrong or it's bugged. There's also seem to be no documentation about it.
I believe this was fixed in 0.2.12.
That said, I ran into this problem in 0.2.15. It turns out that you need to configure the $urlMatcherFactoryProvider
BEFORE the $stateProvider
.
ie the following code will NOT work:
$stateProvider.state('login', {
url: "/login",
templateUrl: 'templates/login.html',
controller: 'loginController as loginCtrl'
});
$urlMatcherFactoryProvider.caseInsensitive(true);
$urlMatcherFactoryProvider.strictMode(false);
You have to configure the $urlMatcherFactoryProvider
first, like this:
$urlMatcherFactoryProvider.caseInsensitive(true);
$urlMatcherFactoryProvider.strictMode(false);
$stateProvider.state('login', {
url: "/login",
templateUrl: 'templates/login.html',
controller: 'loginController as loginCtrl'
});
use like this
app.config(["$routeProvider", "$locationProvider",
function ($routeProvider, $locationProvider) {
return $routeProvider.when("/", {
redirectTo: "/signin"
})
.when("/dashboard", {
templateUrl: "App/views/Dashboard/dashboard.html",
}).when("/signup", {
templateUrl: "App/views/signup/signup.html",
resolve: {
permission: function (authorizationService, $route) {
return authorizationService.permissionCheck("signup");
},
}
})
.when("/myAccount", {
templateUrl: "App/views/myAccount/myAccount.html",
resolve: {
permission: function (authorizationService, $route) {
return authorizationService.permissionCheck("myAccount");
},
}
})
.when("/signin", {
templateUrl: "App/views/signin/signin.html",
resolve: {
permission: function (authorizationService, $route) {
return authorizationService.permissionCheck("SKIP");
},
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.