欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-02-24 11:35:20
npm 安装 ng-bootstrap 模块 npm install @ng-bootstrap/ng-bootstrap --save 在 angular...

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

示例代码

angular + ng-bootstrap

参考文章

ng bootstrap - angular directives specific to bootstrap 4

bootstrap 4 components, powered by angular


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