详解在Angular项目中添加插件ng-bootstrap
npm 安装 ng-bootstrap 模块
npm install @ng-bootstrap/ng-bootstrap --save
在 Angular 项目配置
app.module.ts
添加
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
imports: [
/**
* ngx-bootstrap
*/
NgbModule.forRoot()
],添加 bootstrap.min.css 样式
在 assets 文件夹下 bootstrap/bootstrap.min.css , 并在 style.css 文件中添加
@import "assets/bootstrap/bootstrap.min.css";
测试
app.component.html
添加代码:
<div>
<span> test the ng-bootstrap</span>
<div [(ngModel)]="model" ngbRadioGroup name="radioBasic">
<label class="btn btn-primary">
<input type="radio" [value]="1"> Left (pre-checked)
</label>
<label class="btn btn-primary">
<input type="radio" value="middle"> Middle
</label>
<label class="btn btn-primary">
<input type="radio" [value]="false"> Right
</label>
</div>
<hr>
<pre>{{model}}</pre>
</div>测试结果

示例代码
参考文章
NG Bootstrap - Angular directives specific to Bootstrap 4
相关推荐
liduote 2020-06-16
阿斌Elements 2020-06-11
xxuncle 2020-06-05
ChinaGuanq 2020-06-05
wanghongsha 2020-03-26
csm0 2020-03-05
shyoushine 2020-02-25
electronvolt 2020-02-12
jsonwoo 2020-01-20
ZadarrienChina 2020-01-07
wwwxuewen 2020-01-04
dynsxyc 2020-01-03
liangjielaoshi 2019-12-27
bowean 2019-12-27
wwwxuewen 2019-12-25
liwusen 2019-12-16
颤抖吧腿子 2019-12-16