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

5
2个回答

5

ngx-bootstrap包含由Angular驱动的所有核心(以及非核心)Bootstrap组件。因此,您不需要包含原始JS组件,但我们使用了Bootstrap提供的标记和CSS。

安装说明

请查看官方Github上的入门指南页面。

控件和文档在此处可用

从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样式:
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">

我需要将它安装到我的项目目录中还是全局安装? - Braj Ankit
如果您将在许多不同的项目中重复使用相同的库,则可以全局安装它-g。否则,您只能将其安装在您的项目位置上。 - RajeshKdev
你可以在这里阅读更多关于此的内容:https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/。 - RajeshKdev

2
请使用以下内容:
npm install ngx-bootstrap --save

这里提供了一个链接:

在此输入图片描述


我需要在我的项目目录中安装它还是需要全局安装? - Braj Ankit
在运行ng serve命令的相同目录位置 - Prachi
有没有想法如何安装v7.0.0? - Ambuj Khanna

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接