NgModule suggestion, also "No Provider for NgbDropdown" bug
See original GitHub issueBug description:
First of all, thanks for your library. We switched from ng2-bootstrap and so far we like this one better 😉
Okay, so you guys recommend Users to import the NgbModule
inside our AppModule
- why?
Okay, you don’t have to import any other module from ng-bootstrap in components that are declared in AppModule
. That’s about it.
We in our project like to only include modules that are actually used. We are using webpack to build everything. So with importing NgbModule
the app.js grows in size a lot.
Right now we are doing something like this:
import {NgbDropdownModule} from "@ng-bootstrap/ng-bootstrap/dropdown/dropdown.module";
It would be nice to be able to do something like this:
import {NgbDropdownModule} from "@ng-bootstrap/ng-bootstrap/dropdown";
(So there’d be an index.js exporting all members of NgbDropdown).
Also, there is a bug:
https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/dropdown/dropdown.module.ts#L10
When including NgbDropdownModule
we get No Provider for NgbDropdown as Exception since NgbDropdown isn’t included in the providers
array and therefore we must include it in our AppModule
’s providers
array.
Version of Angular, ng-bootstrap, and Bootstrap:
Angular: 2.4.5
ng-bootstrap: 1.0.0.alpha.20
Bootstrap: 4.0.0-alpha.6
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:12 (6 by maintainers)
Top GitHub Comments
@dhardtke I see what you are after now. Here’s an updated plunker for your use case that does exactly what you wanted (you can see also that only the dropdown is loaded).
http://plnkr.co/edit/tMdJ1Us9pRVM3OB2MTCX?p=preview
The plunker that you have provided has a 500 error as you are getting the bundle, etc. and the path you have provided is wrong. Let me know whether there is anything amiss in this one.
@dhardtke thnx for the warm words. Could you please reproduce in a plunker the issue with providers that you are mentioning here? Please note that you need to use the MgbDropdownModule.forRoot() when importing in the app module.