I am new to Angular 2 and I have a question regarding routing. I have a app.routing file, in which I only want one path.
{path: 'signup', component: SignupComponent}
But if I run this code I get an error:
Error: Uncaught (in promise): Error: Cannot match any routes: ''
So i decided to just use an empty component on the ' ' path, which works exactly like i wanted.
Routing File:
import {Routes, RouterModule} from '@angular/router';
import {SignupComponent} from "./signup/signup.component";
import {EmptyComponent} from "./empty/empty.component";
const appRoutes:Routes = [
{path: '', component: EmptyComponent},
{path: 'signup', component: SignupComponent}
];
export const appRoutingProviders = [];
export const routing = RouterModule.forRoot(appRoutes);
The file with the router-outlet:
<header>
<div class="btn-wrapper">
<button class="btn-sign-up btn-fancy" routerLink="/signup">Sign Up</button>
<button class="btn-sign-in btn-ghost btn-fancy">Sign In</button>
</div>
<i class="material-icons more">keyboard_arrow_down</i>
<router-outlet></router-outlet>
<div class="overlay" *ngIf="overlay" (click)="close()"></div>
<div class="tinted"></div>
</header>
I just want that the router only routes the SignupComponent on the 'signup' path. Is there another way to do this and eliminate the use of an empty component? I am sorry if this question is poorly written, I am very new to StackOverflow.