Two distinct components are interacting with each other.
- I create an invoice, input data, select a client name, and click on Add Product.
- I add a product and navigate back to the invoice component. Upon navigation, the client name gets deleted.
I have found a solution for other data in the invoice component, but I am facing an issue with the client data.
To address this, I created a data service with the following code:
export class DataService {
_data = new Map<string, any>();
setData(key, value) {
this._data.set(key, value);
}
getData(key) {
return this._data.get(key);
}
clear() {
this._data = new Map<string, any>();
}
}
In the InvoiceComponent, I implemented the following code:
client: Client[];
{
// Code implementation
}
ngOnInit() {
// Implementation of logic
}
saveData() {
// Saving data logic
}
onSelect(clientId) {
// Selecting client logic
}
All data displays correctly except for the client information.
To handle the client_id, I updated my HTML code as follows:
HTML snippet:
{/* Updated HTML code */}
Any suggestions or ideas?
Thank you
Changes:
I revised my HTML code to include the modifications below:
{/* Updated HTML code */}
In the TypeScript code, I made the following changes:
{/* Updated TypeScript code */}