23

For some reason, I am suddenly getting this error out of the blue, with no code changes. Any ideas what would be causing this?

I was able to solve this with adding NgbModule.forRoot() to my imports, but now I get this error:

Property 'forRoot' does not exist on type 'typeof NgbModule'.

the application is running fine otherwise.

Dimitar
  • 4,402
  • 4
  • 31
  • 47
Wayn Chaw
  • 495
  • 2
  • 5
  • 11
  • 1
    could you please post some sample code? – Cloxure Oct 10 '16 at 20:45
  • 2
    `NgbModule.forRoot()` is the method you should use from alpha.7, see: https://github.com/ng-bootstrap/ng-bootstrap/blob/master/CHANGELOG.md#breaking-changes. Regarding the "Property 'forRoot' does not exist on type 'typeof NgbModule'." - is it IDE that is reporting it? Your question is not clear here... – pkozlowski.opensource Oct 10 '16 at 21:06

3 Answers3

30

I've got the same problem with you. I tried to add .forRoot() to NgbModule. Try to configure your @NgModule decorator like this:

   imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot(appRoutes),
    NgbModule.forRoot()
  ]

Hope this help.

Hung Vi
  • 490
  • 4
  • 16
15

adding this one on my modules.ts works!

  imports: [
NgbModule.forRoot()
]
1

For Angular 8, Make sure you have added NgbModule in app.module.ts imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(appRoutes), NgbModule // .forRoot() is deprecated in Angular 8 ]

And Downgrading "ng-bootstrap" to 5.x.x worked for me. I found the Angular ng-bootstrap compatibility here. https://www.npmjs.com/package/@ng-bootstrap/ng-bootstrap