当我尝试加载我的 Angular 2.0 应用程序时,出现以下错误:(索引):21 错误:错误:模块“AppModule”导入的意外值“[object Object]”
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { searchComponent } from './search.Component';
import { landingComponent } from './landing.Component';
export const routes: Routes = [
{
path: '',
component: searchComponent
},
{
path: 'search',
component: searchComponent
}];
export const routedComponents = [searchComponent, landingComponent];
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
应用模块
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { landingComponent } from './landing.Component';
import { searchComponent } from './search.Component';
import { routes, routedComponents } from './app.routing';
import { homeScript } from './Services/homeScript';
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
routes
],
declarations: [
landingComponent,
searchComponent,
routedComponents
],
providers: [
homeScript
],
bootstrap: [landingComponent]
})
export class AppModule { }
键入启动脚本
///<reference path="./../typings/globals/core-js/index.d.ts"/>
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './appModule';
platformBrowserDynamic().bootstrapModule(AppModule)
.then(success => console.log(`Bootstrap success`))
.catch(error => console.log('GUY ' + error));
如果我从导入中删除“路线”,登录页面会加载但没有任何错误。我怀疑路由中的错误,因为如果我删除 AppModule 中的“路由”,登录页面会正确加载。我尝试了很多更改,但我无法确定问题的原因。任何帮助,将不胜感激。