0
在我的應用程序componenent,我有以下代碼angular2路由不起作用
import { Component, OnInit} from '@angular/core';
import {aComponent} from './a.component';
import {xService} from './shared';
import {Router, Routes, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from @angular/router';
import {zComponent} from './z.component';
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'x.component.html',
styleUrls: ['x.component.css'],
directives: [
ROUTER_DIRECTIVES],
providers: [
ROUTER_PROVIDERS, cService
]
})
@Routes([
{
path: '/',
component: zComponent
},
{
path: '/admin',
component: aComponent
}
])
export class AppComponent implements OnInit {
constructor(private _router: Router) { }
ngOnInit() {
}
當我鍵入以下URL urlserver /它工作得很好,我zcomponent顯示 但是當我輸入以下網址urlserver/admin,發生錯誤(在此服務器上未找到請求的URL /管理員。)
發生了什麼?爲什麼代碼不起作用?