Skip to content

Instantly share code, notes, and snippets.

@natenault
Created April 4, 2017 05:37
Show Gist options
  • Save natenault/08b9295eed07351cd659caf412d75522 to your computer and use it in GitHub Desktop.
Save natenault/08b9295eed07351cd659caf412d75522 to your computer and use it in GitHub Desktop.
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