get parameters from url in angular 8 code example
Example 1: get url params angular
import { ActivatedRoute, Params } from '@angular/router';
@Component(...)
export class MyComponent implements OnInit {
constructor (private activatedRoute: ActivatedRoute){}
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
if (params.myParam){
}
});
}
}
Example 2: angular set url parameters
<a href="javascript:;" routerLink="/link/params">
My link
</a>
{path: '/link/:paramsName', component: MyComponent }