How to read a parameter in the URL string when opening the start page? If I pass the ID to the URL: mysite.com/productid, and the app will read and remember this ID for future reference ? I want to read the QR-code, which contains the path with ID of the product and go directly to the site to this product section.
Asked
Active
Viewed 353 times
0
-
Refer this stackoerflow answer-https://stackoverflow.com/questions/45997369/how-to-get-param-from-url-in-angular-4 – Brian Sep 26 '19 at 18:34
-
thanks, that was useful – Vasily Asur Sep 26 '19 at 19:46
1 Answers
0
First Create A route in app-routing module file like this
{path: 'test/:id', component: TestComponent}
and get id in your Start Component like this and store in local storage
constructor(
private activeRoute: ActivatedRoute
) {}
ngOnInit() {
const getidfromurl = this.activeRoute.snapshot.paramMap.get('id');
localStorage.setItem('my id',getidfromurl);
}

Mohammed Aamier
- 178
- 7