https://i.sstatic.net/6dcPt.png
https://i.sstatic.net/uFMuL.png
I have two components - one is a form and the other is a dialog with a form. When I click on the dialog with the form and input data, I want to save it first in an in-memory
, and then post all my input from the dialog with the form to the backend. How can I achieve this?
This is what I did to save the form in the in-memory
(calling the generate URL which is 'api/users'):
save(){
this.http.post(this.appsetting.baseURL + 'users', this.serialForm.value).subscribe((res) => {
console.log(res)
})
Here's how my in-memory looks like:
import { Injectable } from '@angular/core';
import { InMemoryDbService } from 'angular-in-memory-web-api';
@Injectable({
providedIn: 'root'
})
export class InMemoryDataService implements InMemoryDbService {
createDb() {
const users = [
{ id: 11, itemCode: 'ICT000000211', qtyReceived:0, inputs:[{
deliveryId: 0,
serialNum:'string'
}] },
];
console.log(users)
return { users : users };
}
}
After saving, I want to post all my in-memory
to my real backend using this code:
PostAll(){
return this.http.post(this.appsetting.baseURL + 'RealBackEnd/PostItem', data)
}