怎么了?我试图让它工作,但我得到的头部错误。我已经包括在 app.component.html
的 <router-outlet></router-outlet>
是被 app.component.ts
调用的 templateUrl
,仍然没有运气。
App.module. ts :
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { TopnavComponent } from './components/navbars/topnav/topnav.component';
import { LeftnavComponent } from './components/navbars/leftnav/leftnav.component';
import { LeftnavsecondaryComponent } from './components/navbars/leftnav-secondary/leftnav-secondary.component';
import { WorldofwarcraftComponent } from './components/games/worldofwarcraft/worldofwarcraft.component';
@NgModule({
imports: [ BrowserModule, FormsModule, AppRoutingModule ],
declarations: [ AppComponent, TopnavComponent, LeftnavComponent, LeftnavsecondaryComponent, WorldofwarcraftComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
App- 路由. module.ts :
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { WorldofwarcraftComponent } from './components/games/worldofwarcraft/worldofwarcraft.component';
const appRoutes: Routes = [
{ path: 'worldofwacraft', component: WorldofwarcraftComponent }
];
@NgModule({
imports: [ RouterModule.forRoot(appRoutes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}