Created
January 23, 2017 17:58
-
-
Save travist/ad065eecc474ce33177cecbcbb02b299 to your computer and use it in GitHub Desktop.
Manual Form.io API
This file contains hidden or 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
| <div ng-controller="FormSubmissionController"> | |
| <formio form="form"></formio> | |
| </div> |
This file contains hidden or 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('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