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

49 Views Asked by At

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');

         }
    }
});
1

There are 1 best solutions below

0
Marcus Höglund On BEST ANSWER

You have a typeo in your $routeProvider config

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

Should be

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