2017-05-09 2 views
2

ui-router를 각도 4에 통합하는 방법. 감안할 때 예는되지도 있습니다 최신 버전으로 작업 (https://ui-router.github.io/ng2/)각도 4 - UI 라우터

package.json

"dependencies": { 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/router": "^4.0.0", 
    "core-js": "^2.4.1", 
    "rxjs": "^5.1.0", 
    "ui-router-ng2": "^1.0.0-beta.1", 
    "zone.js": "^0.8.4" 
    } 

앱 routing.module.ts

import { NgModule } from '@angular/core'; 
import { RouterModule } from '@angular/router' 

import { DashboardComponent } from './components/dashboard/dashboard.component'; 
import { UsersComponent } from './components/users/users.component'; 

/** Routing with ui-router */ 
import { UIRouter } from "ui-router-ng2"; 
let helloState = { name: 'dashboard', url: '/dashboard', component: DashboardComponent }; 
let aboutState = { name: 'users', url: '/users', component: UsersComponent }; 

@NgModule({ 
    imports: [ 
    UIRouter.forRoot({ states: [helloState, aboutState] }) 
    ], 
    exports: [ 
    RouterModule 
    ] 
}) 

export class AppRoutingModule { } 

것 같다 않습니다 'UIRouter.forRoot'에 대한 오류 (forRoot 속성은 존재하지 않습니다). 어떤 도움이나 예가 있습니까? "@의 uirouter/각도"현재로

답변

2

: "^ 1.0.0-beta.6"

당신은 forRoot을 (를)

import { UIRouterModule } from "@uirouter/angular"; 

공식입니다 포함하는, UIRouterModule을 가져올 필요 통합을 보여주는 데모 응용 프로그램 https://ui-router.github.io/ng2/tutorial/helloworld