首页 > 解决方案 > 在组件中使用 Angular Basic 管道

问题描述

我试图在我的 Ionic 项目中的一个组件中使用 Angular 现成的管道(即日期、大写),但它给出了一个错误。

我在 src/app 文件夹中有一个组件文件夹。每个组件都在各自的文件夹中,其中包含 scss、html 和 ts 文件。

<div class="day">
  {{ day | date }}
</div>
<div class="month">
  {{ month | uppercase }}
</div>

我必须在某处导入 DateModule 吗?

标签: angularionic-framework

解决方案


没有任何名为 DateModule 的模块。

日期管道是 CommonModule 的一部分(参见 @angular/common 包)。

CommonModule 导出由 BrowserModule 重新导出,它自动包含在根 AppModule 中(也在 Ionic 项目中)。


推荐阅读