Thuta Learning
ရှာဖွေရန်
AdvancedWeb Developmentintermediate

routerLink & router-outlet

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Navigation အတွက် <a> tag အစား routerLink directive ကိုသုံးသည်။

<router-outlet> directive သည် Angular router က activated component ကို မည်သည့်နေရာတွင် ပြသရမည်ကို ပြောပြသော placeholder ဖြစ်သည်။

typescript
<nav>
  <a routerLink="/home">Home</a>
  <a routerLink="/about">About</a>
</nav>

<router-outlet></router-outlet>

// app-routing.module.ts
const routes: Routes = [
  { path: 'home', component: HomeComponent },
  { path: 'about', component: AboutComponent }
];
You should see
(Home နှင့် About links များကိုနှိပ်လျှင် page refresh မဖြစ်ဘဲ သက်ဆိုင်ရာ component ၏ content ပြောင်းလဲသွားမည်)
routerLink & router-outlet | Thuta Learning