Best way to quickly integrate Bootstrap 3 or Bootstrap 4 Components with Angular
ngx-bootstrap contains all core (and not only) Bootstrap components powered by Angular. So you don't need to include original JS components, but we are using markup and css provided by Bootstrap.
Install ngx-bootstrap
from npm
:
npm install ngx-bootstrap --save
Add needed package to NgModule imports:
import { TooltipModule } from 'ngx-bootstrap/tooltip';
@NgModule({
...
imports: [TooltipModule.forRoot(),...]
...
})
Add component to your page:
<button type="button" class="btn btn-primary"
tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Simple demo
</button>
You will need bootstrap styles:
Bootstrap 3
<!-- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
Bootstrap 4
<!--- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
Use the Angular CLI ng add command for updating your Angular project
ng add ngx-bootstrap
OR use ng add
to add needed component (for example tooltip)
ng add ngx-bootstrap --component tooltip
Add component to your page:
<button type="button" class="btn btn-primary"
tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Simple demo
</button>
Sometimes, your project might contain some library that could interfear with the bootstrap framework, or you might have a customized version of bootstrap. The consequence is that the process of determining bootstrap version might be failed, which can break the UI. In that case, we can still set the bootstrap version manually in the boostraping component (i.e. AppComonent
):
import { setTheme } from 'ngx-bootstrap/utils';
@Component({...})
export class AppComponent {
constructor() {
setTheme('bs3'); // or 'bs4'
...
}
}
Main source of API documentation and usage scenarios available here: https://valor-software.com/ngx-bootstrap/
Additionally you can find demos and docs deployed from latest code with angular v4 and angular v5
Server side rendered version of this documentation available here
Check demo page for API reference
Bootstrap and angular-cli
please refer to using-with-bootstrap-and-angular-cliangular-seed
please refer to getting-started-with-angular-seedsystem.js
(and angular2 quickstart) please checkout sample repositoryplnkr
sample available hereAoT using ngc and rollup
please refer to ngx-bootstrap-with-aotASP.NET Core 2.0
please refer to using-with-asp.net-core-2
First time:
- clone repository
npm install
npm run build
To update your fork and prepare it for local usage:
git pull upstream development
rm -rf node_modules
npm install
npm run build
To run the demo:
npm run demo.serve
// to serve local demo. This is for testing only, without watchers.
For local development run:
npm run build.watch
// in first terminalng serve
// in second
If you want to run the demo with Angular Universal:
npm run demo.serve-universal
So if you are in trouble, here's where you can look for help.
The best place to ask questions is on StackOverflow (under the ngx-bootstrap
tag)
You can also join our Slack channel and link your stackoverflow question there. But try to avoid asking generic help questions directly on Slack since they can easily get lost in the chat. You can also search among the existing GitHub issues.
If, and only if, none of the above helped, please open a new issue.
Are very welcome! And remember, contribution is not only PRs and code, but any help with docs or helping other developers to solve issues are very appreciated! Thanks in advance!
Please read our contribution guidelines.
If you need more modules check here
Please read central ngx
modules readme for details, plans and approach
Crossbrowser testing sponsored by Browser Stack
MIT