var ap=angular.module('mainApp',['ngRoute']); app.config(function($routeProvider){ $routeProvider .when('/',{ templateUrl: 'login.html' }) .when('/dashboard',{ templateUrl: 'dashboard.html' }) .othewise({ redirectTo: '/' }); }); app.controller('loginCtrl', function($scope, $location){ $scope.submit = function(){ var uname = $scope.username; var password = $scope.password; if($scope.username=='admin' && $scope.password =='admin'){ $location.path('/dashboard'); } }; });