【问题标题】:Ionic 3 Lazy Loading with amDateFormat pipe带有 amDateFormat 管道的 Ionic 3 延迟加载
【发布时间】: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

【问题讨论】:

  • 以下链接讨论了处理自定义管道,但我不确定如何将其应用于amDateFormationicacademy.com/ionic-3-lazy-loading
  • 您是否尝试在 page.module.ts 的 ngModule 中导入该模块?
  • 不,我会试一试。我到底要导入什么? import {???} from './angular2-moment/???'
  • 再次感谢 Suraj。这有效import {MomentModule} from 'angular2-moment';。我一如既往地感谢您的宝贵建议。

标签: angular ionic-framework ionic2 ionic3


【解决方案1】:

对于延迟加载,您需要将模块添加到 page.module.ts 的导入中。

import {MomentModule} from 'angular2-moment';

@NgModule({
  imports: [
    MomentModule
  ],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-11
    • 2017-11-20
    • 2017-11-27
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多