模板解析:找不到管道 [英] Template parse: The pipe could not be found
本文介绍了模板解析:找不到管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误:
模板解析错误:无法找到管道'amDateFormat'
Template parse errors: The pipe 'amDateFormat' could not be found
这是我的 app.module.ts
import { NgModule } from '@angular/core';
...
import { MomentModule } from 'angular2-moment';
...
@NgModule({
declarations: [
MyApp
],
imports: [
...
MomentModule,
...
],
bootstrap: [IonicApp],
entryComponents: [
MyApp
],
providers: [
...
]
})
export class AppModule { }
然后在 service-booking-details.ts
我正在做以下事情:
Then in service-booking-details.ts
I am doing the following:
import { Component} from '@angular/core';
import { IonicPage, NavController, NavParams} from 'ionic-angular';
import { MomentModule } from 'angular2-moment';
...
@IonicPage()
@Component({
selector: 'page-item-detail',
templateUrl: 'service-booking-detail.html'
})
export class ServiceBookingDetailPage {
service: any;
...
constructor(..., navParams: NavParams, ...) {
this.service = navParams.get('service');
}
}
然后在服务中 - booking-detail.html
模板我试图使用angular2-moment的管道:
<ion-content>
<ion-card>
<ion-card-content>
<p>{{ service.data | amDateFormat:'LL' }}</p>
</ion-card-content>
</ion-card>
</ion-content>
然后抛出错误模板解析错误:管道'amDateFormat'不能找到。
如何导入MomentModule以便我可以在模板中使用它而不会出错?
How do I import the MomentModule so that I can use it in templates without getting errors?
推荐答案
我能够通过将其导入特定的页面* .module.ts文件来实现这一点。
I was able to get this working by importing this into the specific pages *.module.ts file.
这篇关于模板解析:找不到管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文