首页 > 解决方案 > 仅从 ng-bootstrap 安装 datepicker

问题描述

我想使用 ng-bootstrap 包中的 datepicker: https ://ng-bootstrap.github.io/#/components/datepicker/overview

有没有办法只安装 datepicker 及其依赖项而不是所有包?

标签: angularnpm-installng-bootstrap

解决方案


您不能只安装 datepicker,但您只能在项目中导入 datepicker。

ng-boostrap 导出所有子模块,如果您只想使用 datepicker,您可以只导入 datepicker:

...
import { NgbDatepickerModule } from '@ng-bootstrap/ng-bootstrap';
...
@NgModule({
  imports: [..., NgbDatepickerModule.forRoot()],
  ...

当你构建你的项目时,只有来自 ng-bootstrap 的这个模块会被添加到你的包中。


推荐阅读