如何在我的angular 4项目中安装ngx-bootstrap

时间:2018-05-29 06:30:12

标签: angular ngx-bootstrap-modal

我可能无法将ngx-bootstrap安装到我的angular 4项目中,因此无法使用预定义的模板。我已经通过以下两个链接进行ngx-bootstrap安装,请指导我正确的方法。

https://valor-software.com/ngx-bootstrap/#/getting-started

https://loiane.com/2017/08/how-to-add-bootstrap-to-an-angular-cli-project/

2 个答案:

答案 0 :(得分:5)

ngx-bootstrap包含由Angular提供支持的所有核心(而不仅仅是)Bootstrap组件。因此,您不需要包含原始JS组件,但我们正在使用Bootstrap提供的标记和CSS。

安装说明

查看他们在Github上的官方Getting Started页面。

控件和文档为available here

从npm安装ngx-bootstrap:

npm install ngx-bootstrap --save

向NgModule导入添加所需的包:

import { TooltipModule } from 'ngx-bootstrap/tooltip';

@NgModule({
  ...
  imports: [TooltipModule.forRoot(),...]
  ...
})

向您的网页添加组件:

<button type="button" class="btn btn-primary"
        tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Simple demo
</button>

您将需要引导程序样式:

Bootstrap 3

<!-- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

Bootstrap 4

<!--- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">

答案 1 :(得分:2)

使用此:

npm install ngx-bootstrap --save

它在那里给出了:

enter image description here