I am developing my first angular app and now when it has come to navigating on my page with routerLink, it does not work. It loads up with the welcome component, but when I click on a routerLink it sends me to a blank page.
import { Component } from "@angular/core";
@Component({
selector: 'pm-root',
template: `<nav class="navbar navbar-expand navbar-light bg-light">
<a class="navbar-brand">{{pageTitle}}</a>
<ul class='nav nav-pills'>
<li><a class="nav-link" routerLink='/welcome' routerLinkActive="active">Home</a></li>
<li><a class="nav-link" routerLink='/products' routerLinkActive="active">Product list</a></li>
</ul>
</nav>
<div class="container">
<router-outlet></router-outlet>
</div>`
})
export class AppComponent {
pageTitle: string = 'Acme Project Mangement';
}
And my app.module.ts looks like this
@NgModule({
declarations: [
AppComponent,
ProductList,
ConvertToSpacesPipe,
starComponent,
ProductDetailComponent,
WelcomeComponent
],
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
RouterModule.forRoot([
{path: 'products', component: ProductListComponent},
{path: 'products/:id', component: ProductDetailComponent},
{path: 'welcome', component: WelcomeComponent},
{path: '', redirectTo: '/welcome', pathMatch: 'full'},
{path: '**', redirectTo: 'welcome', pathMatch: 'full'}
])
],
bootstrap: [AppComponent]
})
export class AppModule { }
I can not see any wrong with my code, and the compiler does not throw any error. Please help me so I can go on with angular.