Swadesh
Swadesh

Reputation: 35

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

         }
    }
});

Upvotes: 0

Views: 48

Answers (1)

Marcus Höglund
Marcus Höglund

Reputation: 16801

You have a typeo in your $routeProvider config

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

Should be

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

Upvotes: 1

Related Questions