I am learning Angular 2, I am facing this problem with RC7.
app.routing.ts:
import { ModuleWithProviders, NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; import { LoginRoutes } from './login/index'; import { DashboardRoutes } from './dashboard/index'; const routes: Routes = [ ...LoginRoutes, ...DashboardRoutes //{ path:'', component: GridViewComponent } ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule], providers: [] }) export class Ng2PlayRoutingModule { }
login.routes.ts
import { LoginComponent } from './index'; export const LoginRoutes = [ { path: 'login', component: LoginComponent }, { path: '', redirectTo: 'dashboard/gridview', pathMatch: 'full' } ];
dashboard.routes.ts
import { DashboardComponent } from './index'; import { GridRoutes } from './gridview/index'; export const DashboardRoutes = [ { path: 'dashboard', component: DashboardComponent, children: [ ...GridRoutes ] } ];
Here, when the page loads, it redirects to the dashboard / gridview . And it does not detect anything and gets this error in the console
zone.js:388Unhandled Promise rejection: Invalid configuration of route 'login': one of the following must be provided (component or redirectTo or children or loadChildren) ; Zone: <root> ; Task: Promise.then ;
Help me what causes the problem.
Edit:
Login /index.ts
export * from './login.component'; export * from './login.routes';
source share