2
如何將UI路由器集成到角度4。給出的例子似乎並不與最新版本的工作(https://ui-router.github.io/ng2/)Angular 4 - UI-Router
的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"
}
APP-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'(屬性for root不存在)錯誤。任何幫助或例子?