I run into a simple... but ennoying issue with ModalModule:
I am using: https://github.com/tinesoft/generator-ngx-library to share components between projects.
here:
1) yeoman the lib
2) in the lib import ngx-bootstrap
3) write some code on the existing component ‘LibComponent’. Actually, i copy/pasted the exemple code of modals on ngxboot website.
4) gulp build
5) Try to execute the already defined demo in the library. (inside demo folder).
I have this error:
ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[LibComponent -> BsModalService]:
Thx you in advance for any advice... I'm a bit lost :D.
I did all normal stuff like:
here is the code of the Lib Module:
@NgModule({
imports: [
CommonModule,
FormsModule,
ModalModule.forRoot(),
ReactiveFormsModule,
ButtonsModule.forRoot()
],
exports: [LibComponent],
declarations: [LibComponent]
})
export class LibModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: LibModule,
providers: [LibService]
};
}
}
here is the code of the component:
import { Component, TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({
selector: 'zca-component',
templateUrl: './lib.component.html'
})
export class LibComponent {
modalRef: BsModalRef;
constructor(private modalService: BsModalService) { }
openModal(template: TemplateRef<any>) {
this.modalRef = this.modalService.show(template);
}
}