Why won't my 'routerLink' items navigation work?
It's a new project based on the only changes:
ng new -S --routing home2
app.component.html
<div style="cursor: pointer;"><a routerLink="/page1" routerLinkActive>Page 1</a></div>
<div style="cursor: pointer;"><a routerLink="/page2" routerLinkActive>Page 2</a></div>
<router-outlet></router-outlet>
app.routes.ts
import { Routes } from '@angular/router';
import { Page1Component } from './components/page1/page1.component';
import { Page2Component } from './components/page2/page2.component';
export const routes: Routes = [
{path: 'page1', component: Page1Component},
{path: 'page2', component: Page2Component},
];
After running
ng new -S --routing home2, angular just prepares an infrastructure for using router. You need then to add:RouterLinkandRouterLinkActive(or justRouterModuleinstead of three directives):after adding missing imports your routes should work
Also, you should pass one or several CSS classes to routerLinkActive directive.
For your future questions I would recommend to reproduce your issue using Angular project on STACKBLITZ, this way it will be much easier for others to help you. GOOD LUCK with NG17 :)