2
我遵循Angular2的路由教程。然而,我現在得到一個奇怪的錯誤,我似乎無法修復:Angular2無法解析provideLocationStrategy的所有參數
127.0.0.1/:21錯誤:(SystemJS)無法解析所有參數provideLocationStrategy:(PlatformLocation,?,Token_ROUTER_CONFIGURATION)。
app.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {MyComponent} from "./myComponent/myComponent.component";
const appRoutes: Routes = [
{ path: '', component: MyComponent},
{ path: '**', component: MyComponent}
];
//
//export const appRoutingProviders: any[] = [
//
//];
//
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { routing, appRoutingProviders } from './app.routing';
import { AppComponent } from './app.component';
import {MyComponent} from "./myComponent/myComponent.component";
@NgModule({
imports: [
BrowserModule,
routing
],
declarations: [
AppComponent,
MyComponent
],
providers: [
//appRoutingProviders
],
bootstrap: [
AppComponent
]
})
export class AppModule { }
在其出口appRoutingProviders從app.routing.ts的文檔,但在本教程中,他們不,所以我把它排除了。結果是一樣的,它似乎只是一個空數組。
什麼可能導致此錯誤?
你有' 在index.html頁面上嗎? router-outlet> –