【发布时间】:2018-03-13 05:57:32
【问题描述】:
当单击带有 routerLink 的锚标记时,路由器会成功导航到该路由,但随后会刷新页面。这在 Chrome 和 Edge 上都会发生。
锚点:
<a mat-raised-button color="primary" style="margin-left: 10px;[routerLink]=['/table']">some text</a>
routes.module.ts:
const appRoutes: Routes = [
{ path: "home", component: HomeComponent },
{ path: "content", component: ImageViewComponent },
{ path: "table", component: TableComponent },
{ path: "", redirectTo: "/home", pathMatch: "full" }
];
@NgModule({
imports: [
RouterModule.forRoot(
appRoutes,
{ enableTracing: false }
)
],
exports: [RouterModule]
})
export class AppRoutingModule {}
app.module.ts:
@NgModule({
declarations: [
],
imports: [
BrowserModule,
ServerModule,
AppRoutingModule,
FlexLayoutModule,
MyOwnCustomMaterialModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
使用的 Angular CLI 版本:1.7.3 Angular 路由器版本:5.2.8
【问题讨论】:
-
您的 routerLink 位于内联样式中。可能的原因?
标签: angular typescript angular5 angular-routing