provideRouter and RouterConfig not found in new @angular/router 3.0.0-alpha.3^

后端 未结 4 1080
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 00:01

I am migrating an angular2 app to RC2 and trying to use the router\'s version 3 alpha.

I have followed the set up of the plunker given by the angular docs for routin

4条回答
  •  一向
    一向 (楼主)
    2020-12-16 00:35

    Try to use provideRoutes instead of provideRouter

    import {provideRoutes} from "@angular/router";
    

    and your routing:

    provideRoutes([
        {path: '', redirectTo: '/myurl'}
    ])
    

    UPD For now you don't need provideRouters at all. Just write path and import Routes from '@angular/router';

    import {RouterModule, Routes} from '@angular/router';
    
    const APP_ROUTES: Routes = [
      {path: '', redirectTo: '/somthng', pathMatch: 'full'},
      {path: 'somthng', component: SomthngComponent},
      {path: 'somthng-list', component: SomthngListComponent}
    ];
    
    export const your_routing = RouterModule.forRoot(APP_ROUTES);
    

提交回复
热议问题