Experimental Ivy - routerLink does not trigger navigation event
See original GitHub issue🐞 bug report
Affected Package
The issue is caused by package @angular/router
Is this a regression?
I did not try experimental-ivy in previous versions
Description
The routerLink directive does not work after creating a new Angular project with the experimental-ivy and routing flags on. I created the project using the angular cli and created three components and added them to app-routing.module.ts. Lastly, I added an anchor tag to the app.component.ts with routerLink=“/about”, but the link does not work when previewed on the browser.
Behavior
- When clicking on the link, the browser does not reload nor does it navigate.
- When hovering the link, the browser shows the tooltip on the bottom-left corner, but it shows the current URL rather than the URL I specified in routerLink.
- Inspecting the HTML, the href attribute shows the current url, while the routerLink attribute shows the URL I specified.
- The router-outlet works fine as it loads the components based on their URL correctly. However, it does not update when I click on a link with the routerLink directive.
- After setting ‘enableTracing’ to true inside app-routing.module.ts, when I click on the link the console does not log any navigation events.
🔬 Minimal Reproduction
The project was created with the following command:
ng new FaustoWeb2019 --experimental-ivy true --prefix fausto --routing true --skipt-git true --skip-tests true --style scss
Modified files:
- src/app/app.module.ts
- src/app/app.component.html
- src/app/app-routing.module.ts
- src/app/components/
🔥 Exception or Error
No console or CLI errors
🌍 Your Environment
Angular Version:
7.2.15
Angular CLI Version:
7.3.9
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Angular routerLink does not navigate to the corresponding ...
I suspect that your problem is that you are not importing RouterModule (which is where RouterLink is declared) into the module which uses ......
Read more >What's new in Angular 13? | Ninja Squad
In v13, if you give null or undefined to routerLink , then the navigation is disabled (and the href attribute is removed from...
Read more >In-app navigation: routing to views - Angular
A routed Angular application has one singleton instance of the Router service. When the browser's URL changes, that router looks for a corresponding...
Read more >Angular 13 in Depth - Sébastien Dubois
It no longer emits a 'popstate' event when Location.go is called. In addition, simulateHashChange now triggers both a hashchange and a popstate ...
Read more >Routing & Navigation - Angular
An event triggered when the Router parses the URL and the routes are recognized. ... A wildcard route can navigate to a custom...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The reason here is that ngcc of version 7.2.15 doesn’t properly recognize routerLink input property since it’s a setter. Looks like it has been already covered by https://github.com/angular/angular/pull/28357 @JoostK
Can you please update angular and @angular/cli version to the latest and see if it works? Btw, I already tested it on the latest versions and routing works well.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.