user3508811
user3508811

Reputation: 925

error TS2554: Expected 1-2 arguments, but got 3

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.

Upvotes: 0

Views: 12513

Answers (1)

Will Alexander
Will Alexander

Reputation: 3571

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]

})

Upvotes: 2

Related Questions