Ngx-bootstrap: Dynamic module creation gives "No provider for DatepickerConfig!"

Created on 19 Jan 2017  路  6Comments  路  Source: valor-software/ngx-bootstrap

We are using the DatePicker and TimePicker within our Dynamic Form renderer @ https://form.io in the repo @ https://github.com/formio/ng2-formio.

We are having an issue dynamically creating the DatePicker due to the way you are exporting your modules using the non-standard forRoot method. Here is an example of what we are doing..

import { NgModule, Compiler, Component, ComponentFactory } from '@angular/core';
import { DatepickerModule, TimepickerModule } from 'ng2-bootstrap';

@NgModule({
  imports: [
    DatepickerModule.forRoot(),
    TimepickerModule.forRoot()
  ]
})
class DynamicComponentModule {}

...
compiler.compileModuleAndAllComponentsAsync(DynamicComponentModule)

It seems that the structure that you return within forRoot is not expected for dynamic module creation and causes an error.

blocked

Most helpful comment

I had same issue with Progressbar module: No provider for ProgressbarConfig! and I didn't call .forRoot() in my lazy loaded module. I was thinking it would just work when I import it in lazy loaded module.
UPDATE: Basically by adding ProgressbarModule to imports array in app.module with .forRoot() and in lazy loaded module without .forRoot() solved my problem.
I thought only adding it in app.module would suffice, but no, it's also required to be added in lazy loaded module .

All 6 comments

you can reconstruct it as static module https://github.com/valor-software/ng2-bootstrap/blob/development/src/datepicker/datepicker.module.ts

and is more or less standard
https://angular.io/docs/ts/latest/guide/ngmodule.html#!#core-for-root

I am afraid it is @angular issue, try to create one

Thanks for the feedback. I was unaware of that construct. I will submit an issue with @angular.

Thanks again.

np :) just link this issue, so I could track progress, give me a note if you will need something

Here is the bug report into @angular.

https://github.com/angular/angular/issues/14022

Thanks again for your help.

I had same issue with Progressbar module: No provider for ProgressbarConfig! and I didn't call .forRoot() in my lazy loaded module. I was thinking it would just work when I import it in lazy loaded module.
UPDATE: Basically by adding ProgressbarModule to imports array in app.module with .forRoot() and in lazy loaded module without .forRoot() solved my problem.
I thought only adding it in app.module would suffice, but no, it's also required to be added in lazy loaded module .

@travist seems it is fixed, drop me a note if not ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ctrl-brk picture ctrl-brk  路  3Comments

tuoitrexuquang picture tuoitrexuquang  路  3Comments

KimBum picture KimBum  路  3Comments

MrBlaise picture MrBlaise  路  3Comments

phmello picture phmello  路  3Comments