Created
December 7, 2015 21:32
-
-
Save sax1johno/eb1001d900572f9c68eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('us.propl.app') | |
.controller('applyController', function($http, localStorageService) { | |
// var AppResource = $resource('/api/apply'); | |
// this.applied = localStorageService.get('applied'); | |
this.applied = false; | |
var that = this; | |
this.submit = function() { | |
this.application.username = this.application.email; | |
$http.post("/api/apply", this.application) | |
.then(function(applicationResponse) { | |
console.log("Application was saved successfully", applicationResponse); | |
console.log(applicationResponse.data.errors); | |
if (_.isUndefined(applicationResponse.data.errors)) { | |
console.log("Success"); | |
// localStorageService.set("applied", true); | |
that.applied = true; | |
} else { | |
console.log("There were errors", applicationResponse.data.errors); | |
that.errors = applicationResponse.data.errors; | |
} | |
}, function(errorResponse) { | |
console.log("Error processing application", errorResponse); | |
}); | |
// var appFields = this.application; | |
// var application = new AppResource(appFields); | |
// application.$save().$promise.then(function(thisApplication) { | |
// console.log("Application was saved successfully", thisApplication); | |
// }, function(err) { | |
// console.log("There was an error saving your application", err); | |
// }); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment