col*_*r-j 2 ionic2 angular2-moment angular
我收到错误消息:
模板解析错误:找不到管道“ amDateFormat”
这是我的 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 { }
Run Code Online (Sandbox Code Playgroud)
然后在service-booking-details.ts执行以下操作:
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');
}
}
Run Code Online (Sandbox Code Playgroud)
然后在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>
Run Code Online (Sandbox Code Playgroud)
然后,它引发错误“ 模板解析错误:找不到管道'amDateFormat' ”。
如何导入MomentModule,以便可以在模板中使用它而不会出现错误?
| 归档时间: |
|
| 查看次数: |
2952 次 |
| 最近记录: |