Issue
How can I receive a parameter passed by state in the URL on another page? I have this code to send the parameter to the next page.
let costcountry = this.requestAmountData.costCenterCountryId
this.router.navegateByUrl(`exampleurl`, {state: { costcountry: costcountry}});
But I don't know how to receive it to use it on the next page. any ideas? TK
Solution
Try This Approach with ActivatedRoute
:
Page 1:
gotoYourPage(paramsToSend){
this.router.navigate(['/YourPageName', { yourDataKey : JSON.stringify(paramsToSend)}]);
}
Page2:
import { ActivatedRoute } from '@angular/router';
constructor(
private aroute: ActivatedRoute
) { }
this.receiveData = JSON.parse(this.aroute.snapshot.params.yourDataKey );
Answered By - Najam Us Saqib
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.