早上好 ,
我很想知道,你是如何在项目中引入ngx-bootstrap模块的?什么是推荐和最佳做法。
谢谢
正如在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();