app-routing.module.ts
settings.py
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {PostListComponent} from './post/post-list.component';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'posts', component: PostListComponent},
]
@NgModule({
imports: [ RouterModule.forRoot(routes)],
exports: [ RouterModule ]
})
export class AppRoutingModule{
}
**app.component.html**
答案 0 :(得分:0)
我知道我没有将 App-routing.module 导入我的 App.module.ts
中import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { PostListComponent } from './post/post-list.component';
import { PostService} from './post/post.service';
import { HomepageComponent } from './homepage/homepage.component';
@NgModule({
declarations: [
AppComponent,
PostListComponent,
HomepageComponent
],
imports:[
BrowserModule,
HttpClientModule,
**AppRoutingModule**
],
providers: [
PostService
],
bootstrap: [AppComponent]
})
export class AppModule { }