javascriptangularjsangularjs-ng-route

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

         }
    }
});

Solution

  • You have a typeo in your $routeProvider config

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

    Should be

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