我在路由时遇到问题,单击链接之前Angular会显示组件

时间:2019-04-27 15:18:03

标签: angular

我在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 { }

0 个答案:

没有答案