I have a simple program where I am trying to redirect use using a check on username and password. But when condition holds true I am not redirected but instead given an error. Can someone help me out?
SNIPPET:
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular-route.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
Username: <input type="text" ng-model="username"><br>
Password: <input type="password" ng-model="password"><br>
<button ng-click="submit()">LogIn</button>
<script>
//module declaration
var app=angular.module("myApp",['ngRoute']);
//routing declaration
app.config(function($routeProvider, $httpProvider){
$routeProvider
.when('/login',{
templateUrl: 'login.html'
})
.when('/dashboard',{
templateUrl: 'dashboard.html'
})
.otherwise({
templateUrl: 'login.html'
});
});
//controller declaration
app.controller("myCtrl",function($scope, $location){
$scope.submit= function(){
if($scope.username=='admin' && $scope.password=="admin")
{
$location.path('/dashboard');
//alert("Hi");
}
};
});
</script>
</body>
</html>
ERROR:
Running the folder in XAMPP