【发布时间】:2017-05-04 15:21:21
【问题描述】:
我正在使用 Ionic3,并且正在转换为延迟加载以提高启动性能。
将ChatsPage 转换为延迟加载后,我遇到了管道问题。正如您在下面看到的,它抱怨在我的chats.html 中使用以下行。
<h3 class="chat-time">{{item.timestamp | amDateFormat: 'D MMM YYYY'}}</h3>
ERROR Error: Uncaught (in promise): Error: Template parse errors: The pipe 'amDateFormat' could not be found ("item.memberId2 && !item.lastMsg_read2))}">{{item.lastMsg_text}}</p> <h3 class="chat-time">{{[ERROR ->]item.timestamp | amDateFormat: 'D MMM YYYY'}}</h3> </ion-item> "): ng:///ChatsPageModule/ChatsPage.html@28:32 Error: Template parse errors: The pipe 'amDateFormat' could not be found ("item.memberId2 && !item.lastMsg_read2))}">{{item.lastMsg_text}}</p> <h3 class="chat-time">{{[ERROR ->]item.timestamp | amDateFormat: 'D MMM YYYY'}}</h3> </ion-item>
问题
知道如何通过延迟加载处理amDateFormat (angular2-moment) 吗?
更多信息:
Your system information:
Cordova CLI: 6.4.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.9.4
Xcode version: Xcode 8.3.2 Build version 8E2002
【问题讨论】:
-
以下链接讨论了处理自定义管道,但我不确定如何将其应用于
amDateFormat? ionicacademy.com/ionic-3-lazy-loading -
您是否尝试在 page.module.ts 的 ngModule 中导入该模块?
-
不,我会试一试。我到底要导入什么?
import {???} from './angular2-moment/???' -
github.com/urish/angular2-moment
MomentModule -
再次感谢 Suraj。这有效
import {MomentModule} from 'angular2-moment';。我一如既往地感谢您的宝贵建议。
标签: angular ionic-framework ionic2 ionic3