Skip to content

Instantly share code, notes, and snippets.

@randallknutson
Created October 14, 2016 19:36
Show Gist options
  • Save randallknutson/0a83f1afde7c281b666739a1044b9e87 to your computer and use it in GitHub Desktop.
Save randallknutson/0a83f1afde7c281b666739a1044b9e87 to your computer and use it in GitHub Desktop.
Create form wrapper with submit message.
angular.module('spryapp')
.directive('spryform', function () {
return {
restrict: 'E',
replace: true,
scope: {
src: '=',
message: '=',
form: '=?',
submission: '=?'
},
template: '' +
'<div>' +
' <formio ng-if="!submitted" src="src" form="form" submission="submission"></formio>' +
' <div ng-if="submitted">{{ message }}</div>' +
'</div>',
controller: ['$scope', function ($scope) {
$scope.submitted = false;
$scope.$on('formSubmission', function(submission) {
$scope.submitted = true;
});
}]
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment