I just started learning Angular2 and created a sample project in which i need to route between three pages.
I created a RouterModule in the app.module.ts as the following
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule,
RouterModule.forRoot([
{path:'login',component : loginComponent},
{path:'logout',component :logoutComponent},
{path:'home',component : homeComponent}
])
my app.component.ts is as the following:
@Component({
selector: 'my-app', // <my-app></my-app>
providers: [Wakanda],
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
my loginComponent.ts
@Component({
selector:'login',
template : `
<h1>Login</h1>
`
})
my logoutComponent.ts
@Component({
selector:'logout',
template : `
<h1>Login</h1>
`
})
my homeComponent.ts
@Component({
selector : 'home',
template : `
<h1>Login</h1>
`
})
my app.component.html
<header>
<nav>
<div class="nav-wrapper">
<ul class="right hide-on-med-and-down">
<li>
<a routerLink ="./home">Home</a>
</li>
<li class="active">
<a routerLink="./login">LogIn</a>
</li>
<li>
<a routerLink="./logout">Log out</a>
</li>
</ul>
</div>
</nav>
</header>
<main>
<router-outlet></router-outlet>
</main>
When i compile the program i am getting an error as
EXCEPTION: Uncaught (in promise): Error: Cannot match any routes: ''
Can anyone help me in solving this issue
Thanks in advance