ng-bootstrap modal is not displaying

萝らか妹 提交于 2019-12-05 07:31:30

I faced the same problem, the issue was with CSS. When I check the elements of the document, find that the modal elements was created but not showing in the screen. Below css has solved the issue.

   .modal-backdrop.fade
   {
     opacity: 0.5;
   }
   .modal-open .modal
   {
     opacity: 1;
   }

ng-bootstrap only works with Bootstrap 4, not compatible with Bootstrap 3.

As @Ansar Samad pointed out it only works with bootstrap 4. If you need it in a Bootstrap 3 project you can checkout https://www.npmjs.com/package/ng-bootstrap-to-bootstrap-3

Intructions:

  • npm install ng-bootstrap-to-bootstrap-3

  • import 'ng-bootstrap-to-bootstrap-3' somewhere in your code.

That's it!

I also had same problem, and found out that I was not including css link for bootstrap in my styles.css. Although I was using ng-bootstrap with bootstrap v4.

@import url('../node_modules/bootstrap/dist/css/bootstrap.min.css');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!