错误无法解析setupRouter的所有参数

时间:2016-09-02 08:26:11

标签: angularjs angular typescript

我收到错误“在创建路由的基本应用时无法解析RouteParams的所有参数”

下面是我的app.module.ts文件,似乎是

import { NgModule }       from '@angular/core';
import { BrowserModule }  from '@angular/platform-browser';
import { FormsModule }    from '@angular/forms';
import { HttpModule }    from '@angular/http';


import { App } from './app';
   import { routing } from './components/appRouting/app.routing';
   import { LoginComponent } from './components/login/loginComponent';
   import {SliderMenuComponent} from './components/sliderMenu/sliderMenuComponent';

      @NgModule({
       imports: [
         BrowserModule,
         FormsModule,
         routing,
         HttpModule
       ],
       declarations: [App,LoginComponent,SliderMenuComponent],
       providers: [],
       bootstrap: [App]
     })
     export class AppModule { }

我的app.routing.ts如下所示:

import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {LoginComponent} from '../login/loginComponent';
import {SliderMenuComponent} from '../sliderMenu/sliderMenuComponent';
const appRoutes: Routes = [
  {
    path: '',
    redirectTo: '/login',
    pathMatch: 'full'
  },
  { path: 'login', component: LoginComponent },
  { path: 'slider', component: SliderMenuComponent }
    ];
export const appRoutingProviders: any[] = [
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

我的app.ts如下所示:

从'@ angular / core'导入{Component};

@Component({
   selector: 'app',
   template : `
   <h1 class="title">Component Router</h1>
   <nav>
     <a routerLink="/slider" routerLinkActive="active">Slider</a>
     <a routerLink="/login" routerLinkActive="active">Login</a>
    </nav>
    <router-outlet></router-outlet>
  `
})
export class App {
}

1 个答案:

答案 0 :(得分:2)

将角度路由器更新为“@ angular / router”:“3.0.0-rc.2”并且它现在正在工作