Search code examples
twitter-bootstrapangularng2-bootstrap

How to switch from Bootstrap 3 to Bootstrap 4 with ng2-bootstrap?


I am using ng2-bootstrap for an Angular 2 project.

This package supports both Bootstrap 3 and 4. After I install it, it uses Bootstrap 3 by default. I didn't find any information about switching.

How can I switch from Bootstrap 3 to Bootstrap 4? Should I write something in the file tsconfig.json?

Thank you!


Solution

  • You have to set the theme to bootstrap4

    import {Ng2BootstrapConfig, Ng2BootstrapTheme} from '../ng2-bootstrap';    
    
    Ng2BootstrapConfig.theme = Ng2BootstrapTheme.BS4;
    

    Note: The above code should be used before your main component. The same place where you will use angular2's enableProdMode();