Last active
July 12, 2023 14:56
Enable Save As Draft in Angular.
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
import debounce from 'lodash/debounce'; | |
@Component({ | |
... | |
}) | |
export class MyController { | |
public submission = {}; | |
ngAfterViewInit() { | |
var currentSubmission = localStorage.getItem('currentSubmission-' + this.route.params.formId); | |
if (currentSubmission) { | |
this.submission = JSON.parse(currentSubmission); | |
this.cdr.detectChanges(); | |
} | |
} | |
onChange(submission) { | |
localStorage.setItem('currentSubmission-' + submission.form, JSON.stringify(submission)); | |
} | |
} |
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
<formio [src]="formURL" (change)="onChange($event)" [submission]="submission" [renderOptions]="{ | |
saveDraft: true, | |
saveDraftThrottle: 10000 | |
}"></formio> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment