mohammadreza
mohammadreza

Reputation: 23

NullInjectorError: No provider for NgbModalRef

I try to use NgbModalRef to close a Modal (That open with NgbModal) and in some components I see the Error:

ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(MyModule)[NgbModalRef -> NgbModalRef -> NgbModalRef -> NgbModalRef -> NgbModalRef]: NullInjectorError: No provider for NgbModalRef!


Note1:I have imported and Injected NgbModalRef and NgbModal in my component and tried using NgbModule in my appModule and it didnt Work! Note2:I saw somewhere that people say to write NgbModalRef in appModule provider,and i dont think its the right way because its not a Service!! Can anyone please help..

Upvotes: 2

Views: 2811

Answers (1)

Imamul Karim Tonmoy
Imamul Karim Tonmoy

Reputation: 584

i solved this problem using this reference.

https://github.com/ng-bootstrap/ng-bootstrap/issues/1832#issuecomment-331798666

from private modalReference: NgbModalRef;

to private modalReference: any;

Upvotes: 0

Related Questions