I'm new to angular with rest api. Simple login page to home page navigation with java , rest api, with angular js 1. But on click of login button it redirects to same login page. But I could see logs and no error.
This is my app.js
var loginapp = angular.module('loginapp' ,['ngRoute','ngResource']);
loginapp.config(['$routeProvider', function($routeProvider) {
console.log("config");
$routeProvider
.when('/', {
templateUrl: 'login.html',
controller: 'loginController'
})
.when('generate-report', {
templateUrl: 'generate-report.html',
controller: 'generatexml'
})
.otherwise({
redirectTo: '/generate-report'
});
}]);
loginapp.controller('loginController',['$scope', '$http', function
($scope,$http) {
$scope.submitlogin = function (response) {
console.log("submit login called")
$http({
method : 'POST',
url : 'login',
data : '',
headers : {
'Content-Type' : 'application/json'
}
}).then( response );
}
}]);
my html code
<body ng-app="loginapp">
<div class="login-box" ng-controller="loginController">
<form>
<input id="inputUserId" type="text" >
<input id="inputPassword" type="password" >
<button ng-click="submitlogin()" >Sign in</button>
</form>
</div>
</body>
This is my java controller class @Controller public class LoginController {
@RequestMapping(value="/" , method = RequestMethod.GET)
public String viewLogin(Model model) {
System.out.println("login controller");
return "login";
}
@RequestMapping(value="/login", method = RequestMethod.POST)
public String submitLogin() {
System.out.println("Login controller - submitLogin");
return "generate-report";
}
}