带有 amDateFormat 管道的 Ionic 3 延迟加载 [英] Ionic 3 Lazy Loading with amDateFormat pipe

查看:13
本文介绍了带有 amDateFormat 管道的 Ionic 3 延迟加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ionic3,并且正在转换为延迟加载以提高启动性能.

ChatsPage 转换为延迟加载后,我遇到了管道问题.正如您在下面看到的,它抱怨在我的 chats.html 中使用以下行.

 <h3 class="chat-time">{{item.timestamp |amDateFormat: 'D MMM YYYY'}}</h3>

<块引用>

ERROR 错误:未捕获(在承诺中):错误:模板解析错误:找不到管道'amDateFormat' ("item.memberId2 && !item.lastMsg_read2))}">{{item.lastMsg_text}}</p><h3 class="chat-time">{{[错误 ->]item.timestamp |amDateFormat: 'D MMM YYYY'}}</h3></离子项目>"): ng:///ChatsPageModule/ChatsPage.html@28:32错误:模板解析错误:找不到管道'amDateFormat' ("item.memberId2 && !item.lastMsg_read2))}">{{item.lastMsg_text}}</p><h3 class="chat-time">{{[错误 ->]item.timestamp |amDateFormat: 'D MMM YYYY'}}</h3></离子项目>

问题

知道如何通过延迟加载处理 amDateFormat (angular2-moment) 吗?

更多信息:

您的系统信息:科尔多瓦 CLI:6.4.0离子框架版本:3.0.1离子 CLI 版本:2.1.18离子应用程序库版本:2.1.9离子应用脚本版本:1.3.0ios-deploy 版本:未安装ios-sim 版本:未安装操作系统:macOS Sierra节点版本:v6.9.4Xcode 版本:Xcode 8.3.2 Build 版本 8E2002

解决方案

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

从'angular2-moment'导入{MomentModule};@NgModule({进口:[时刻模块],

I am using Ionic3, and am in the process of converting to Lazy Loading in order to improve startup performance.

I am experiencing a problem with pipes after converting my ChatsPage to lazy loading. As you can see below, it is complaining about the use of the following line in my 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>

Question

Any idea how to handle amDateFormat (angular2-moment) with lazy loading?

More info:

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

解决方案

For lazy loading you need to add the module to imports of the page.module.ts.

import {MomentModule} from 'angular2-moment';

@NgModule({
  imports: [
    MomentModule
  ],

这篇关于带有 amDateFormat 管道的 Ionic 3 延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆