Presently, I am utilizing a modal material dialog window that prompts the user to input a number and then press search. Upon searching, it retrieves data from an API call and receives a response object. My goal is to utilize this response object to populate a new page (edit form).
My inquiry is, how can I transfer the data, specifically the number entered by the user on the material dialog component, to another component so that it can retrieve the API call results? Or how can I transmit my response object to my edit form from the dialog?
For example:
This is my search function:
search(searchNumber) {
if (this.selectedOption === 'Bill Number') {
this._transactionService.findExistingTransactionByBillNumber('U001', searchNumber)
.subscribe(data => this.transactionResponse = data);
console.log(JSON.stringify(this.transactionResponse));
this.router.navigate(['/edit-transaction-portal']);
} else {
this._transactionService.findExistingTransactionByTransactionNumber('U001', searchNumber)
.subscribe(data => this.transactionResponse = data);
console.log(JSON.stringify(this.transactionResponse));
this.router.navigate(['/edit-transaction-portal']);
}
}
I would like to either 1) send the response object obtained here or send the searchNumber entered by the user, so that I can perform a lookup within my edit form component. I need to pass either one from this component to the new component that I navigate to.
EDIT: The accepted solution demonstrates how to add query params to this.router.navigate() and how to retrieve it by subscribing to activateRoute, a different approach than the one identified in the other SO post.