当前位置: 移动技术网 > IT编程>脚本编程>AngularJs > 详解在Angular项目中添加插件ng-bootstrap

详解在Angular项目中添加插件ng-bootstrap

2017年12月12日  | 移动技术网IT编程  | 我要评论

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


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网