Files
roboto-promoto/app/scripts/controllers/login.js
Fergal Moran d49dc8b3bf Initial Commit
2014-03-20 11:32:56 +00:00

26 lines
607 B
JavaScript

'use strict';
angular.module('robotoApp')
.controller('LoginCtrl', function ($scope, Auth, $location) {
$scope.user = {};
$scope.errors = {};
$scope.login = function(form) {
$scope.submitted = true;
if(form.$valid) {
Auth.login({
email: $scope.user.email,
password: $scope.user.password
})
.then( function() {
// Logged in, redirect to home
$location.path('/');
})
.catch( function(err) {
err = err.data;
$scope.errors.other = err.message;
});
}
};
});