如何在 Angular html 模板的属性中应用管道

How to apply pipe in attribute in Angular html template

如何在我的 i 标签中应用 angular 日期 pipe?以下代码无效:

<i class="fas fa-mouse-pointer font-14 status-icon-active mr-3"
    *ngIf="recentDate"
   [tooltip]="[recentDate| date: 'medium']"> -- error Here
</i>

您可以使用 angular 数据绑定或插值技术

tooltip="{{recentDate | date: 'medium'}}" // Using interpolation

[tooltip]="recentDate | date: 'medium'" // Data binding

这大概是在指责插值吧。你应该像

这样写打字稿
<i [tooltip]="recentDate | date: 'medium'">

<i tooltip="{{recentDate | date: 'medium'">

这些都行。

你应该替换:

[tooltip]="[recentDate| date: 'medium']"

作者:

[tooltip]="recentDate | date: 'medium'"