angular 2 cli 下使用 ng-bootstrap
angular 2 cli 下使用 ng-bootstrap
十万猛虎下画山 发表于3个月前
angular 2 cli 下使用 ng-bootstrap
  • 发表于 3个月前
  • 阅读 14
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

摘要: 原文链接https://ng-bootstrap.github.io/#/home

地址 需要翻墙:https://ng-bootstrap.github.io/#/home

Dependencies

This repository contains a set of native Angular directives based on Bootstrap's markup and CSS. As a result no dependency on jQuery or Bootstrap's JavaScript is required. The only required dependencies are:

  • Angular (requires Angular version 4 or higher, tested with 4.0.3)
  • Bootstrap CSS (tested with 4.0.0-beta
  •  
  • Bootstrap要单独安装妈蛋的。
  • npm install bootstrap@4.0.0-beta
  • 我说一直报错找不到css呢,css要放在angular-cli.json的style中 )
     "styles": [
            "../node_modules/bootstrap/dist/css/bootstrap.min.css",
            "styles.css"
          ],

     

Should I add bootstrap.js or bootstrap.min.js to my project?

No, the goal of ng-bootstrap is to  completely replace JavaScript implementation for components. Nor should you include other dependencies like jQuery or popper.js. It is not necessary and might interfere with ng-bootstrap code.

Supported browsers

We strive to support the same browsers and versions as supported by both Bootstrap 4 and Angular, whichever is more restrictive. Check browser support notes for Angular and Bootstrap.

Our code is automatically tested on all the supported browsers.

Installation

After installing the above dependencies, install ng-bootstrap via: 

(安装完上述依赖之后,安装@ng-bootstrap模块和ng-bootstrap样式)
npm install --save @ng-bootstrap/ng-bootstrap

Once installed you need to import our main module.

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

The only remaining part is to list the imported module in your root module and any additional application modules that make use of the components in this library. The exact method will be slightly different for the root (top-level) module for which you should end up with the code similar to (notice NgbModule.forRoot()):

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgbModule.forRoot(), ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Other modules in your application can simply import NgbModule:

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  declarations: [OtherComponent, ...],
  imports: [NgbModule, ...]
})
export class OtherModule {
}
标签: angular angular cli
共有 人打赏支持
粉丝 3
博文 58
码字总数 32110
×
十万猛虎下画山
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: