javascript - How to config Angular ui-router to not use strict URL matching mode - Stack Overflow

ui-router's version 0.2.11 introduced option to turn off strict URL matching, but I can't fig

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.

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.

Share asked Sep 23, 2014 at 11:46 Ondrej SlintákOndrej Slinták 32k21 gold badges96 silver badges127 bronze badges 2
  • Is there an equivalent github issue open? (I can't seem to get this to work either) – Nate-Wilkins Commented Oct 22, 2014 at 17:44
  • 2 @Nate github./angular-ui/ui-router/issues/1395 It should be fixed in master. I'm waiting for next release to test it. – Ondrej Slinták Commented Nov 3, 2014 at 19:24
Add a ment  | 

2 Answers 2

Reset to default 8

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.

i.e. 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");
                },
            }
        })

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744815547a4595302.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信