/**
* Created by cklimkowsky on 2/24/15.
*/
angular
.module('coopEval')
.controller('EmployerController', EmployerController);
function EmployerController($scope, $rootScope, $location, employerService) {
$scope.credentials = {
username: '',
password: ''
};
if ($location.path() == '/employers') {
// On the Overview page, get the student's co-op history
employerService.getPlacementData()
.success(function (result) {
$scope.overviewData = result;
});
}
$scope.login = function (credentials) {
employerService.login(credentials)
.success(function () {
$rootScope.userType='Employer';
delete $rootScope.message;
$location.path('/employers');
})
.error(function () {
$location.path('/employers/login');
var errorContent;
if($scope.credentials.username == undefined) {
errorContent = 'Your username is invalid. Please ensure you entered the correct email address.';
} else {
errorContent = 'Your log-in information is incorrect.';
}
// Todo: Error handling - get error from server to be more specifc?
$rootScope.message = {
type: 'danger',
content: errorContent,
location: $location.path()
};
})
}
} |