2017-01-20 44 views
0

私はAngular2で新しくなりました。エラーにthisAngular2 - 関数 'UIRouterModule'を呼び出すと、関数呼び出しはサポートされません。

ERRORを参照

このエラー私はUIRouterModuleをインポートするとき、私は取得していますが、静的シンボル値を解決遭遇しました。関数 'UIRouterModule'を呼び出すと、関数呼び出しはサポートされません。関数またはラムダを、/site_root/src/app/app.module.ts内のAppModuleシンボルを解決し、/site_root/src/app/app.module.tsのAppModuleシンボルを解決して、エクスポートされた関数への参照で置き換えることを検討してください。

app.module.tsは、私が間違ってやっている

import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { FormsModule } from '@angular/forms'; 
import { HttpModule } from '@angular/http'; 
import { RouterModule, Routes } from '@angular/router'; 
import { UIView, UIRouterModule } from "ui-router-ng2"; 

import { AppComponent } from './app.component'; 
import { ProfileComponent } from './profile/profile.component'; 
import { WidgetComponent } from './widget/widget.component'; 
import { DashboardComponent } from './dashboard/dashboard.component'; 
import { MyRootUIRouterConfig } from "./router.config"; 

import {MAIN_STATES} from "./app.states"; 

const appRoutes: Routes = [ 
    { path: '', component: DashboardComponent }, 
    { path: 'profile', component: ProfileComponent }, 
    { path: 'widget', component: WidgetComponent }, 
]; 

@NgModule({ 
    declarations: [ 
    AppComponent, 
    ProfileComponent, 
    WidgetComponent, 
    DashboardComponent 
    ], 
    imports: [ 
    BrowserModule, 
    FormsModule, 
    HttpModule, 
    RouterModule.forRoot(appRoutes), 
    UIRouterModule.forRoot({ 
     states: MAIN_STATES, 
     otherwise: { state: 'app', params: {} }, 
     useHash: true, 
     configClass: MyRootUIRouterConfig 
    }) 
    ], 
    providers: [], 
    bootstrap: [AppComponent, UIView] 
}) 
export class AppModule { } 

のですか?

答えて

0

私はあなたがそれをドキュメントにそのように書かれているようUIRouterModule.forChild({

UIRouterModule.forRoot({を変更する必要があると思います。

アプリケーションは、forRoot()を使用して1つのNgModuleを作成し、インポートする必要があります。他のすべてのモジュールは、UIRouterModule.forChildを使用して作成する必要があります。

https://ui-router.github.io/ng2/docs/latest/classes/ng2.uiroutermodule.html

+0

まだ同じエラーが発生しています。 –

+0

私はこのクイックスタートを参照しています - https://github.com/ui-router/quickstart-ng2/tree/master –

0

あなたはui-router-ng2バージョン1.0.0-beta.4に更新する必要があります。

1.0.0-beta.4 releaseには、Ahead of Timeのサポートが変更されています。これらの同じ変更は、"function calls are not supported"エラーメッセージに対処する必要があります。

+0

大丈夫です。確認して、あなたに連絡します。 –

関連する問題