Created
April 4, 2017 05:37
-
-
Save natenault/08b9295eed07351cd659caf412d75522 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('demoApp', ['ngMessages']) | |
.controller('FormCtrl', function($scope, FormFactory) { | |
$scope.formData = {}; | |
$scope.submitAppForm = function() { | |
FormFactory.sendFormData($scope.postData) | |
.then(function(resp) { | |
// process response | |
}) | |
.catch(function(error) { | |
// handle errors | |
}); | |
}; | |
}) | |
.factory('FormFactory', function($http) { | |
var sendFormData = function (message) { | |
return $http({ | |
method: 'POST', | |
url: '/api/messages', | |
data: message | |
}); | |
}; | |
return { | |
sendFormData: sendFormData | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment