Softhinker.com
Softhinker.com

Reputation: 895

Angular library project uses ng-bootstrap

I'm creating an Angular 5 library project where ng-bootstrap is used, and it's working fine when ng serve from its own project folder. Now, it is installed to another Angular 5 app project, and when launching the app, it gives this exception:

    ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[NgbTypeahead -> NgbTypeaheadConfig]: 
  StaticInjectorError(Platform: core)[NgbTypeahead -> NgbTypeaheadConfig]: 
    NullInjectorError: No provider for NgbTypeaheadConfig!
Error: StaticInjectorError(AppModule)[NgbTypeahead -> NgbTypeaheadConfig]: 
  StaticInjectorError(Platform: core)[NgbTypeahead -> NgbTypeaheadConfig]: 
    NullInjectorError: No provider for NgbTypeaheadConfig!

In the library project, I've added NgbModule.forRoot() to app.module.ts, and I also tried to add NgbModule.forRoot() to the app project but it doesn't work. Furthermore, I don't think the dependencies configuration used in library project should be re-declared in the app project.

Please advise on this case. Thank you very much.

Upvotes: 1

Views: 650

Answers (1)

Softhinker.com
Softhinker.com

Reputation: 895

NgbModule.forRoot() should be added in the feature.module.ts in library project instead of app.module.ts. And then reinstall it to the app, it works.

Upvotes: 1

Related Questions