Q1. How do you integrate Bootstrap with Angular?
There are several ways: install Bootstrap via npm (
npm install bootstrap) and add the CSS file to angular.json styles array. Or use Angular-specific libraries like ng-bootstrap (Bootstrap components for Angular) or MDBootstrap. You can also include Bootstrap CDN links in index.html.Q2. What is ng-bootstrap?
ng-bootstrap is a library that provides native Angular directives and components for Bootstrap 5, without relying on jQuery or Bootstrap''s JavaScript. It includes widgets like modals, tooltips, datepickers, and accordions built specifically for Angular. To install:
npm install @ng-bootstrap/ng-bootstrapQ3. How do you add Bootstrap CSS to angular.json?
After installing Bootstrap via npm, open angular.json and add the Bootstrap CSS file path to the styles array under "build" and "test" configurations:
"styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.css" ]Q4. Can you use Bootstrap classes directly in Angular templates?
Yes, once Bootstrap CSS is included, you can use Bootstrap classes directly in your HTML templates like any other CSS classes. For example:
For interactive components (dropdowns, modals), you''ll need JavaScript, which can be handled by ng-bootstrap.Q5. What is the advantage of using ng-bootstrap over standard Bootstrap?
ng-bootstrap components are built specifically for Angular, meaning they work seamlessly with Angular''s change detection, lifecycle hooks, and data binding. They don''t require jQuery, reducing bundle size. They provide type-safe APIs and follow Angular best practices, making them easier to integrate into Angular applications.
