1、关上终端,输出命令新建一个angular app
ng new app
2、集成bootstrap
装置ngx-bootstrap
和 Bootstrap
在新建的我的项目中关上终端,运行如下命令
npm install ngx-bootstrap bootstrap --save
3、应用bootstrap款式
配置我的项目:必须将我的项目其配置为包含Bootstrap CSS,能力应用bootstrap的款式。
在angular.json中减少bootstrap的款式:从我的项目的根目录关上文件angular.json,找到Style配置项,指定bootstrap.min.css的门路。实现后,它应如下所示:
"styles": [ "src/styles.sass", "./node_modules/bootstrap/dist/css/bootstrap.min.css" ],
留神:对angular.json进行更改时,您将须要重新启动ng服务以获取配置更改。
4、在app.module.ts
中引入要应用的ngx-bootstrap module
关上src/app/app.module.ts
并增加
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';...@NgModule({ ... imports: [BsDropdownModule.forRoot(), ... ], ...})
具体应用哪个bootstrap组件,点击https://valor-software.com/ngx-bootstrap/#/documentation查看