How to use pipes in Component

前端 未结 3 1099
名媛妹妹
名媛妹妹 2020-12-09 16:20

I want to use the datePipe in my component. I followed the instructions here but I am met with

Error: StaticInjectorError[DatePipe]: 
StaticInjectorError[Da         


        
3条回答
  •  轮回少年
    2020-12-09 16:43

    Add in the Module providers: [DatePipe],

    Add in the constructor private datePipe: DatePipe

    Add in Ts file for Form Array:

    const start_date = this.datePipe.transform(starttime, 'hh:mm a');
    const end_date = this.datePipe.transform(endtime, 'hh:mm a');
    this.Form.controls['starttime'].patchValue(start_date);
    this.Form.controls['endtime'].patchValue(end_date);
    

提交回复
热议问题