-1
The URL 'user/1' for example, it doesn’t work. But I use '/user? id=1' works and I can list but it’s not in the format I want.
In my builder I declared an attribute ActivatedRoute
, which I use in my method ngOnInit()
.
My declaration of routes:
const routes: Routes = [
{ path: ':id', component: UserComponent}
];
Man ngOnInit
within the UserComponent
:
ngOnInit(): void {
this.route.queryParams.subscribe((params: any) => {
this.userId = params['id'];
console.log(this.userId);
});
}
What am I doing wrong?