When submitting a long-form, it is important to ensure that no data is lost. Users should be able to stay on the same page to make any necessary changes after clicking the submit button. I need to receive the unique id generated by the server upon submission so that data can be updated based on that id instead of creating a new one. You can find links to my service and HTML below:
Here is my TypeScript code:
onSubmit(form: NgForm) {
if (form.value.projectproposalid == null) {
this.projectService.postProposal(form.value)
.subscribe(data => {
this.projectService.selectedproposal.projectproposalid = data.projectproposalid;
this.toastr.success('New Record Added Successfully', 'Your Proposal Registered');
});
}
else {
this.projectService.putProposal(form.value.projectproposalid, form.value)
.subscribe(data => {
this.toastr.info('Record Updated Successfully!', 'Your Proposal Updated');
});
}
}