简体   繁体   中英

$location.path is not redirecting to page in Angular JS

Here is the code.In URL it is redirecting to #!/dashboard but it is not displaying anything.

var app = angular.module("myapp", ["ngRoute"]);
app.config(function ($routeProvider) {
    $routeProvider.when("/", {
        templateUrl: "Login.html"
    }).when("/dashboard", {
        tepmlateUrl: "Dasu.html"
    });
});

app.controller("LoginCtrl", function ($rootScope, $location, $scope) {
    $scope.submit = function() 
    {
        debugger;
        if($scope.userid == 'admin' && $scope.password == 'admin')
         {
            $rootScope.LoggedIn = true;

            $location.path('/dashboard');

         }
    }
});

You have a typeo in your $routeProvider config

.when("/dashboard", {
        tepmlateUrl: "Dasu.html"
});

Should be

.when("/dashboard", {
        templateUrl: "Dasu.html"
});

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM