1. Url changed but page not loaded
Reason: The
<router-outlet>is not in the html template.
Solution: Add the<router-outlet>to the template file.
1 | <!-- app.component.html --> |
2. ERROR RuntimeError: NG04002: Cannot match any routes. URL Segment: ‘login’
Reason: Route ‘login’ is not defined in the router configuration.
Solution: Add the route to the router configuration.
1 | // app-routes.ts |
Reason 2: You use
canMatchguard in route configuration and the guard return false.
Solution: Make sure the guard returns true.
1 | { |
3. NG8001: ‘router-outlet’ is not a known element
Reason: The
RouterModuleis not imported in the module.
Solution: Import theRouterModulein the module.
1 | // Module based component(app.module.ts) |