Angular တွင် RouterModule ဖြင့် single-page application အတွက် client-side routing ကို စီမံခန့်ခွဲသည်။ App project အသစ်ဆောက်စဉ် routing ထည့်မည့် option ကို ရွေးချယ်နိုင်သည်။
typescript
// app-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: '**', component: PageNotFoundComponent } // 404 page
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
// app.module.ts
import { AppRoutingModule } from './app-routing.module';
@NgModule({
imports: [BrowserModule, AppRoutingModule]
})You should see
(Routing module configured ဖြစ်ပြီး navigation လုပ်နိုင်သည်)