Removing # from url in Angularjs while having .run in routes

后端 未结 7 651
感情败类
感情败类 2020-11-27 07:02

Here is my app.js route file in AngularJS

var app = angular.module(\'myApp\', [\'ngRoute\', \'ngAnimate\', \'toaster\']);
app.config([\'$routeP         


        
7条回答
  •  抹茶落季
    2020-11-27 07:35

    The problem is it is missing the service injection. So in config section try injecting $locationProvider like below.

    app.config(['$routeProvider', '$locationProvider',
    function ($routeProvider, $locationProvider) {
        $routeProvider.
                when('/login', {
                    title: 'Login',
                    templateUrl: 'resources/views/layouts/loginUser.php',
                    controller: 'authCtrl'
                })
                .when('/', {
                    title: 'Login',
                    templateUrl: 'resources/views/layout/login.php',
                    controller: 'logoutCtrl'
                })
                .when('/reset', {
                    title: 'Reset Password',
                    templateUrl: 'resources/views/layouts/forgetPassword.php',
                    controller: 'authCtrl'
                })
                .when('/invalidtoken', {
                    title: 'Login',
                    templateUrl: 'resources/views/layout/invalidtoken.php',
                    controller: 'authCtrl',
                    role: '0'
                })
    
                $locationProvider.html5Mode(true);
    }])
    

提交回复
热议问题