Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to format the output of the Primeng Range Calender for both dates to be 'dd/MM/yyyy' like this, and I tried to use pipe to transform the these data.

(我想像这样将两个日期的Primeng Range日历的输出格式设置为“ dd / MM / yyyy”,并且尝试使用管道转换这些数据。)

But is only only transforming the first date, and not the second.

(但是,仅改变第一个日期,而不是第二个。)

Html code is:

(HTML代码是:)

<div>{{rangeDates | date: 'dd/MM/yyyy'}}</div>

Ts file is:

(ts文件是:)

  rangeDates: Date[];

I'm getting this error:

(我收到此错误:)

Error: InvalidPipeArgument: 'Unable to convert "Mon Dec 02 2019 00:00:00 GMT+0100 (Central European Standard Time),Tue Dec 10 2019 00:00:00 GMT+0100 (Central European Standard Time)" into a date' for pipe 'DatePipe'
  ask by Ivana translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
330 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this

(尝试这个)

<div *ngFor="let range of rangeDates"">
    {{range | date: 'dd/MM/yyyy'}}
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...