Skip to content

Instantly share code, notes, and snippets.

@travist
Created January 23, 2017 17:58
Show Gist options
  • Save travist/ad065eecc474ce33177cecbcbb02b299 to your computer and use it in GitHub Desktop.
Save travist/ad065eecc474ce33177cecbcbb02b299 to your computer and use it in GitHub Desktop.
Manual Form.io API
<div ng-controller="FormSubmissionController">
<formio form="form"></formio>
</div>
angular.module('myApp')
.controller('FormSubmissionController', [
'Formio',
'$http',
function(Formio, $http) {
$scope.form = null;
// Render the form manually. This will not call the Form.io API when it is submitted, but rather
// just trigger the formSubmission event.
(new Formio('https://myproject.form.io/myform')).loadForm().then(function(form) {
$scope.form = form;
});
// Handle the submission.
$scope.$on('formSubmission', function(event, submission) {
// This will now send the submission to your API. You can also modify it before it is sent here.
$http.post('https://api.yourdomain.com/resource', submission);
});
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment