How to remove hash from URL in Angular5?

2019-07-14 00:36发布

Angular Routing(In my app-routing.module.ts)

@NgModule({
    exports: [ RouterModule ],
    imports: [ RouterModule.forRoot(routes) ],
    declarations: []
})

In index.html I have added <base href="/">

But in the URL I can see the # My application is deployed on JBoss AS 7.1.1 Server

标签: angular jboss
1条回答
Root(大扎)
2楼-- · 2019-07-14 00:59

In your app module do this. Find more information in here about hash location strategy.

@NgModule({
  imports: [
  // other imports
    RouterModule.forRoot(routes, { useHash: false })
  ],
  declarations: [
  ],
  providers: [

  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }
查看更多
登录 后发表回答