There is no directive with "exportAs" set to "bs-modal" when using ng2-bootstrap

You need to import ngx-bootstrap modal module on your module like below:

import { ModalModule } from "ngx-bootstrap";
@NgModule({
  imports: [
    ModalModule.forRoot()
    ]
})

You must be missing the below line in your component

@ViewChild('staticModal') public staticModal:ModalDirective;

For more information on ng2-bootstrap modal you can see this post which contains the demo as well.


Just incase if you are on this thread because you are getting same error even if you have added following line to NgModule

ModalModule.forRoot()

Make sure your import is the correct one.

Correct import

import { ModalModule } from 'ngx-bootstrap/modal';

Wrong import

import { ModalModule } from 'ngx-bootstrap/modal/public_api';