Trying to figure out what the situation is with IonRouterLink and RouterLink with standalone components.
I just did an upgrade progress and ran the schematics to update Angular, which added in the RouterLink imports.
Then I did the Ionic schematic (npx @ionic/angular-standalone-codemods) which ended up adding in the IonRouterLink throughout.
But then I removed RouterLink thinking it was a “mistake” of the Angular migration that wasn’t Ionic aware, and the routerlink attributed buttons stopped working.
So I looked on the docs, and saw that they say don’t use the IonRouterLink with Angular projects:
So I thought it must be an issue with the codemods schematic, but when I looked into that, it seems that it was explicitly added into the project with discussion:
It’s specifically for Angular projects, so they certainly seem to have intended to use IonRouterLink in Angular standalone projects.
My suspicion is that IonicModule maybe included IonRouterLink in the background with some nuance; it does seem to do something related to router links:
So is the conclusion that:
You need to include the Angular and Ionic routerlinks for standalone components
The documentation is out of date, and different guidance is needed for standalone components
Actually, after writing all this out, I dug further in the docs and found that there is some clarification scattered around, eg in the Routing section of the Build Options:
I’ve submitted a pr to add a note to the ion-router-link documentation page to make this more discoverable.