详解在Angular项目中添加插件ng-bootstrap
- 作者: 彬77225821
- 来源: 51数据库
- 2021-08-19
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>
测试结果

示例代码
angular + ng-bootstrap
参考文章
ng bootstrap - angular directives specific to bootstrap 4
bootstrap 4 components, powered by angular
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
推荐阅读
热点文章
Angular中响应式表单的三种更新值方法详析
7
Angularjs实现下拉框联动的示例代码
7
详解AngularJS跨页面传值(ui-router)
2
详解AngularJS1.x学习directive 中‘& ’‘=’ ‘@’符号的区别使用
3
angular2路由切换改变页面title的示例代码
4
Angular2 组件间通过@Input @Output通讯示例
5
Angularjs中ng-repeat的简单实例
3
AngularJS 中ui-view传参的实例详解
4
浅谈Angular路由守卫
4
详解基于Angular4+ server render(服务端渲染)开发教程
4
