Usually you don't submit a form in AngularJS. You send the data using an XHR and get a response in JSON.
Something like this:
VIEW
<form name="myForm" ng-submit="login(credentials)">
<label>
Username:
<input type="text" ng-model="credentials.username" />
</label>
<label>
Password:
<input type="password" ng-model="credentials.password" />
</label>
<button type="submit">Login</button>
</form>
CONTROLLER
$scope.credentials = {};
$scope.login = function login(credentials) {
var user = credentials.username;
var pass = credentials.password;
// Do some data validation
if (!user || !pass) {
$window.alert('Please, enter a username and a password!');
return;
}
// Send the data and parse the response
// (usually done via a Service)
LoginService.login(user, pass);
};
See, also, this short demo.