使用AsDefault"已在angular2.0.0-rc1中移除?
解决方法是什么?在Angular文档中,我已经看过使用OnInit ..
Subroutes是否仍然可以使用/ ...表示法?
干杯
答案 0 :(得分:0)
为angular2工作嵌套路由代码:" @ angular / router":" 2.0.0-rc.1"即使用新路由器如下:
父路线:
import {Component} from '@angular/core';
import {Router,Routes,ROUTER_DIRECTIVES} from '@angular/router';
import {Login} from '../login/login';
import {Dashboard} from '../dashboard/dashboard';
import {Admin} from '../admin/admin';
let template = require('./app.html');
@Component({
selector: 'auth-app',
template: template,
directives: [ROUTER_DIRECTIVES],
})
@Routes([
{path: '/login', component: Login},
{path: '/dashboard', component: Dashboard},
{path: '/admin', component: Admin }
])
export class App{
constructor(public router: Router) {
}
}
儿童路线
import { Component} from '@angular/core';
import { CORE_DIRECTIVES } from '@angular/common';
import { Router, ROUTER_DIRECTIVES ,Routes} from '@angular/router';
import {AddUsrCat} from './addUsrCat/addUsrCat';
import {AllUsr} from './allUsr/allUsr';
declare var jQuery:JQueryStatic;
let template = require('./admin.html');
@Component({
selector: 'admin',
directives: [CORE_DIRECTIVES, ROUTER_DIRECTIVES],
template: template
})
@Routes([
{path: '/addUsrCat', component: AddUsrCat},
{path: '/allUsr', component: AllUsr},
{path: '*', component: AddUsrCat},
])
export class Admin {
constructor(public router: Router, public http: Http) {
}
}
克隆此项目A basic Angular2 ("2.0.0-rc.1") project with authentication (login / logout) works as seed project使用 @ angular / router 即新路线