角度路由器不工作,但也没有错误

时间:2016-09-22 15:28:12

标签: javascript angularjs

我是angularjs的新手。我有两个路由器文件 auth_router.js teacher_router.js auth_router.js 工作正常,但 teacher_router.js 无效。代码如下:

app.js文件

angular.module("learn_mart", ['ngRoute', 'ngCookies'])
    .run(function($rootScope, $cookies) {
        $rootScope.baseurl = "http://localhost/lm/auth.html#";

        $rootScope.userrole = $cookies.get('userrolecookie');
        $rootScope.activetab = $cookies.get('activetabcookie');


        $rootScope.redirectologin = function(role) {
            $cookies.put('activetabcookie', 1);
            $cookies.put('userrolecookie', role);

            window.location = $rootScope.baseurl + '/' + role + "_login";
        };
    });

auth_router.js文件

angular.module("learn_mart")
    .config(function($routeProvider) {
        $routeProvider
            .when("/sub_login", {
                controller: "subscriber_login",
                templateUrl: 'views/auth/subscriber_login.html'
            })
            .when("/sub_register", {
                controller: "subscriber_registration",
                templateUrl: 'views/auth/subscriber_registration.html'
            })
            .when("/tech_login", {
                controller: "teacher_login",
                templateUrl: 'views/auth/teacher_login.html'
            })
            .when("/tech_register", {
                controller: "teacher_registration",
                templateUrl: 'views/auth/teacher_registration.html'
            })
            .when("/shop_login", {
                controller: "shop_login",
                templateUrl: 'views/auth/shop_login.html'
            })
            .when("/shop_register", {
                controller: "shop_registration",
                templateUrl: 'views/auth/shop_registration.html'
            })
    });

teacher_router.js

angular.module("learn_mart")
    .config(function($routeProvider) {
        $routeProvider
            .when("/teacher_course", {
                controller: "show_courses_teacher",
                templateUrl: "views/auth/shop_login.html"
            })
    });

文件包含没有问题。此外,开发人员控制台中也没有显示错误。

0 个答案:

没有答案