我需要将* ngFor循环下的每个日期{{gallery.created}}更改为新的Date(gallery.created)。我的意思是我需要调用新的Date(timestamp) 在* ngFor循环下。但是它不起作用,我可以在控制台中获取值,但是HTMl无法呈现它
<div *ngFor="let gallery of galleries; trackBy: trackHero">
<p> Published on {{this.dateValue| surveysDate:'date':'short'}}</p>
</div>
Ts
public trackHero(index, gallery) {
this.dateValue = new Date(gallery.created);
console.log(this.dateValue);
}
下面尝试的另一种方法是使用相同的HTML格式。但是它填充了每个元素的所有日期
this.someService.search(query).then((response: any) => {
if (response) {
this.galleries = response.results;
this.dateValue = this.galleries.map((x: any) => new Date(x.created));
}
});