Skip to content

Instantly share code, notes, and snippets.

@sax1johno
Created December 7, 2015 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sax1johno/eb1001d900572f9c68eb to your computer and use it in GitHub Desktop.
Save sax1johno/eb1001d900572f9c68eb to your computer and use it in GitHub Desktop.
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