将ngx-bootstrap合并到项目中的最佳实践是什么?

问题描述 投票:0回答:1

早上好 ,

我很想知道,你是如何在项目中引入ngx-bootstrap模块的?什么是推荐和最佳做法。

谢谢

angular typescript ngx-bootstrap
1个回答
2
投票

正如在official documentation中所写,您需要导入需要在angular module中使用的功能模块。

例如,假设您需要使用Datepicker,您将导入它:

import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';


@NgModule({
  imports: [BsDatepickerModule.forRoot(),...]
})
export class AppModule(){}

然后您就可以在模块中使用DatePicker。

例如,将其添加到组件的一个模板中:

<input
  #dp="bsDatepicker"
  bsDatepicker
  [bsValue]="bsValue"
>

在这种情况下,您需要在组件的类中初始化bsValue

 bsValue = new Date();
© www.soinside.com 2019 - 2024. All rights reserved.