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

后端 未结 4 1069
被撕碎了的回忆
被撕碎了的回忆 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:34

    I had the same issue, solved it with using Version 3.0.0-alpha.7

    Here my package.json:

    "dependencies": {
    "@angular/common":  "2.0.0-rc.2",
    "@angular/compiler":  "2.0.0-rc.2",
    "@angular/core":  "2.0.0-rc.2",
    "@angular/http":  "2.0.0-rc.2",
    "@angular/platform-browser":  "2.0.0-rc.2",
    "@angular/platform-browser-dynamic":  "2.0.0-rc.2",
    "@angular/router":  "3.0.0-alpha.7",
    "@angular/upgrade":  "2.0.0-rc.2",
    "systemjs": "0.19.31",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "^0.6.12",
    "angular2-in-memory-web-api": "0.0.12",
    "bootstrap": "^3.3.6",
    "contentful": "3.3.14"}
    

    Altough I wouldn't call it stable and the new Documentation https://angular.io/docs/ts/latest/guide/router.html can be bit missleading.

    0 讨论(0)
  • 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);
    
    0 讨论(0)
  • 2020-12-16 00:42

    Also wrestled with this for a few hours, upgraded to beta7. Remember to change system.config.js as they changed packagenames to index.js (e.g. "platform-browser-dynamic/platform-browser-dynamic.js" is now named "platform-browser-dynamic/index.js".

    But now I can't seem to get a default route to work, is it ''?

    EDIT: Default routing is simply:

    {
        path: '',
        redirectTo: 'index.php/component/atkstat/dashboard'
    }, 
    
    0 讨论(0)
  • 2020-12-16 00:49

    You need to add this line as @angular/router No umd for router yet

    packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };
    

    Have a look package.json and system.config.js of this is , may help you

    http://plnkr.co/edit/y31K7xbiQSVH59qsAOZF?p=preview

    0 讨论(0)
提交回复
热议问题