2017-01-20 13 views
0

저는 Angular2에서 새로 생겼습니다. 오류에 thisAngular2 - 'UIRouterModule'함수를 호출 할 때 함수 호출이 지원되지 않습니다.

오류를 참조

이 오류 나는 UIRouterModule을 가져올 때 내가 갖는은 정적 심볼 값을 해결 발생했습니다. 함수 'UIRouterModule'을 호출하면 함수 호출이 지원되지 않습니다. 함수 또는 람다를 /site_root/src/app/app.module.ts에서 AppModule 심볼을 해석하고 /site_root/src/app/app.module.ts에있는 AppModule을 해석하여 내 보낸 함수에 대한 참조로 대체하는 것을 고려하십시오.

어디 내가 잘못

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 { } 

, app.module.ts을 내?

답변

0

나는 당신이이 문서에 그렇게 기록 된대로 UIRouterModule.forChild({

UIRouterModule.forRoot({을 변경할 필요가 있다고 생각합니다.

응용 프로그램은 forRoot()를 사용하여 단일 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

알겠습니다. 확인하고 다시 연락 할 것입니다. –

관련 문제