Modal EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'parentInjector' of undefined
When trying to open a modal in my component, I get the following error:
EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'parentInjector' of undefined
Been trying the exact same code as the demo:
<button class="btn btn-primary" (click)="lgModal.show()">Large modal</button>
<div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="lgModal.hide()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Large modal</h4>
</div>
<div class="modal-body">
...
</div>
</div>
</div>
</div>
What could have gone wrong?
@theunreal Did you remember to include the viewContainerRef:ViewContainerRef into your application root component? Link Modals Hack
Yes @DawidvanGraan , I noticed that I get this error only inside specific component, and this component is inside a
I'm getting this error and couldn't solve it. wats the fix?
@priteshacharya read the important notes in doc http://valor-software.com/ng2-bootstrap/#/modals
Including the ViewContainerRef in the root application's constructor did the trick for me. Thanks!