【发布时间】:2019-12-19 22:14:20
【问题描述】:
任何帮助或提示将不胜感激!! 我正在关注有关路由的角度文档:https://angular.io/guide/router 我在里程碑 2 的末尾:路由模块。
这是我的 angular-router-sample\src\app\app-routing.module.ts:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CrisisListComponent } from './crisis-list/crisis-list.component';
import { HeroListComponent } from './hero-list/hero-list.component';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent },
{ path: 'heroes', component: HeroListComponent },
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent}
];
@NgModule({
declarations: [],
imports: [
RouterModule.forRoot(
appRoutes,
{ enableTracing: true } // <--debugging purposes only
),
AppRoutingModule
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
这是我的 angular-router-sample\src\app\app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { CrisisListComponent } from './crisis-list/crisis-list.component';
import { HeroListComponent } from './hero-list/hero-list.component';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
@NgModule({
declarations: [
AppComponent,
CrisisListComponent,
HeroListComponent,
PageNotFoundComponent
],
imports: [
BrowserModule,
FormsModule,
AppRoutingModule,
// AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
这是我的控制台日志错误:
【问题讨论】:
标签: angular routing angular-ui-router