Angular之ng-bootstrap使用

ng-bootstrap是Angular上的Bootstrap库,需要Angular5.0以上版本和BootstrapCSS。避免在angular-cli.json中引入bootstrap.js,以免影响ng-bootstrap。安装通过npm,然后在主模块和子模块中导入NgbModule,注意forRoot()的使用。ng-bootstrap经过全面浏览器测试,目前没有发现兼容问题。
摘要由CSDN通过智能技术生成

如果需要使用ng-bootstrap,必须依赖以下两个东西:
1、Angular需要时5.0以上版本
2、需要引入Bootstrap CSS
注:不要在配置文件angular-cli.json中,引入bootstrap.js或bootstrap.min.js文件,这个可能会影响ng-bootstrap的运行。
ng-bootstrap官方说“Our code is automatically tested on all the supported browsers.”,意思做了全浏览器测试,目前还没有发现什么兼容问题。

安装:

npm install --save @ng-bootstrap/ng-bootstrap

安装完成后,需要先将模块引入到主模块和各个需要使用ng-bootstrap的模块中,主要区别是主模块上加上forRoot(),例如:

//----app.module.ts中代码
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgbModule.forRoot(), ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

//----other.module.ts中代码
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  declarations: [OtherComponent, ...],
  imports: [NgbModule, ...]
})
export class OtherModule {
}

翻译自: https://ng-bootstrap.github.io/#/getting-started

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT飞牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值