Last active
July 12, 2023 14:56
-
-
Save travist/fc10ab3ebdfc5e2e8b9929efb2e6ef18 to your computer and use it in GitHub Desktop.
Enable Save As Draft in Angular.
This file contains 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 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