Search code examples
angularangular-standalone-components

Error: Can't bind to 'routerLink' since it isn't a known property of 'a'. with standalone component in Angular 15


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>


Solution

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

    bootstrapApplication(AppComponent, {
      providers: [
        provideRouter(routes),
    ]})