Get your own Angular server
main.ts
index.html
 
import { bootstrapApplication } from '@angular/platform-browser';
import { Component } from '@angular/core';
import { provideRouter, RouterOutlet, RouterLink, RouterLinkActive, withHashLocation } from '@angular/router';

@Component({
  standalone: true,
  template: `<p>Home works!</p>`
})
export class Home {}

@Component({
  standalone: true,
  template: `<p>About works!</p>`
})
export class About {}

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, RouterLink, RouterLinkActive],
  styles: [`
    nav a { margin-right: 8px; text-decoration: none; }
    .active { font-weight: 600; color: seagreen; }
  `],
  template: `
    <h3>Active Links (routerLinkActive)</h3>
    <nav>
      <a routerLink="/" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }">Home</a>
      <a routerLink="/about" routerLinkActive="active">About</a>
    </nav>
    <router-outlet></router-outlet>
  `
})
export class App {}

const routes = [
  { path: '', component: Home },
  { path: 'about', component: About }
];

bootstrapApplication(App, {
  providers: [provideRouter(routes, withHashLocation())]
});

                    
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Angular Router - Active Links</title>
</head>
<body>
  <app-root></app-root>
</body>
</html>