oglimmer/lunchy

View on GitHub
src/main/webapp/js/index/controllers/LunchyControllerLoginRegister.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

/* Controllers */

angular.module('LunchyApp.controllers').
controller('LunchyControllerLoginRegister', ['$scope', 'UserDao', 'OfficesDao', function ($scope, UserDao, OfficesDao) {
    
    $scope.newUser = {};

    OfficesDao.query(function(offices) {
        $scope.offices = offices;
    });

    $scope.submitRegister = function() {    
        var newUser = new UserDao($scope.newUser);
        newUser.$save(function(result) {
            if(result.success) {
                $scope.$uibModalInstance.close(result);
            } else {
                $scope.alerts.push({type:'danger',msg:result.errorMsg});
            }
        });        
    };
    
}]);