0
votes

I am trying to add { useHash: true } to RouterModule.forRoot and running into below error,is there a way to add more arguments?

@NgModule({
  imports: [RouterModule.forRoot(
    appRoutes,
    { enableTracing: true } ,// <-- debugging purposes only
    { useHash: true }
  )],
  exports: [RouterModule]

})

ERROR:-

ERROR in src/app/app-routing.module.ts(26,5): error TS2554: Expected 1-2 arguments, but got 3.

1

1 Answers

2
votes

The second argument to RouterModule.forRoot is a configuration object, so I think what you're after is this:

@NgModule({
  imports: [RouterModule.forRoot(
    appRoutes,
    { enableTracing: true, useHash: true }
  )],
  exports: [RouterModule]

})