在您的项目中结合ngx-boostrap的最佳实践是什么

时间:2018-09-03 14:57:53

标签: angular typescript ngx-bootstrap

早上好,

我很想知道,您如何在项目中加入ngx-bootstrap模块。建议和最佳做法是什么。

谢谢

1 个答案:

答案 0 :(得分: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();