0

I have a standalone component called home, but I am not able to have dynamic routerLinks in it even if I have imported RouterModule in my [imports] of my component. I do not have ngModules in my app to import it in app module.

This simple dynamic url was not working, what am I doing wrong? <a [routerLink]="url">Button</a>

poshy23
  • 23
  • 4

2 Answers2

0

I'm not sure how your url in the component but you can use it look like

in component:

url: string = './users';

in template:

<a [routerLink]="[url]">Button</a>

let me know if it works for you?

Sonu Sindhu
  • 1,752
  • 15
  • 25
0

Remember that in standalone components you not import RouterModule, you need add as provider when you bootstrap the aplication:

bootstrapApplication(AppComponent, {
  providers: [
    provideRouter(routes),
]})
Eliseo
  • 50,109
  • 4
  • 29
  • 67