W3Schools Tryit Editor

[フレーム]
Get your own Angular server
main.ts
index.html
import { bootstrapApplication } from '@angular/platform-browser';
import { Component } from '@angular/core';
import { provideRouter, RouterOutlet, RouterLink, withHashLocation } from '@angular/router';
@Component({
 selector: 'app-root',
 standalone: true,
 imports: [RouterOutlet, RouterLink],
 template: `
 <h3>Router</h3>
 <nav>
 <a routerLink="/">Home</a> |
 <a routerLink="/about">About</a>
 </nav>
 <router-outlet></router-outlet>
 `
})
export class App {}
@Component({
 selector: 'home-view',
 standalone: true,
 template: `<p>Home works!</p>`
})
export class Home {}
@Component({
 selector: 'about-view',
 standalone: true,
 template: `<p>About works!</p>`
})
export class About {}
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</title>
</head>
<body>
 <app-root></app-root>
</body>
</html>
 

AltStyle によって変換されたページ (->オリジナル) /