menu

Questions & Answers

Pages Shown up but Texts are not display Angular

i am a beginner of angular.i am creating a small website on angular.i set routes successfully.but when i click the url links goes to the paticular page but text are not visible i don't why what i tried so far i attached below.

Routes Sections

const routes: Routes = [
  {path: '', component: IndexComponent},
  {path: '/about', component: AboutComponent},
  {path: '/contact', component: ContactComponent}
];

app.component.html

<div class="container">
  <div class="row">
      <div class="col-md-12">
          <h1>Welcome</h1>
      </div>
  </div>

<div class="row">
  <div class="col-md-3">
      <ul class="list-group">
          <a href="/" class="list-group-item">Index</a>
          <a href="/about" class="list-group-item">About</a>
          <a href="/contact" class="list-group-item">Contact</a>
        </ul>
  </div>
</div>
<router-outlet></router-outlet>
</div>

about.component.html

<h1>About</h1>

<p>about works!</p>

contact.component.html

<p>contact works!</p>
Comments:
2023-01-23 08:42:04
I think you need to use routerLink instead of href.
2023-01-23 08:42:04
<a routerLink ="/" class="list-group-item">Index</a> i used like this way but now links are not shown up
Answers(0) :