我在Angular路由方面遇到麻烦。单击链接之前,Angular会显示组件。我的代码如下:
<div>
<h1>
Having trouble with Routing
</h1>
<h1>Router Example</h1>
<a routerLink="/student" routerLinkActive="active">Crisis Center</a>
</div>
<router-outlet></router-outlet>
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { StudentComponent } from './student/student.component';
import { StudentDetailsComponent } from './student-details/student-details.component';
const routes: Routes = [
{
path: 'student',
component: StudentComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }