Pattern analysis: tube not found

I get an error message:

Template parsing errors: could not find tube 'amDateFormat'

Here is my 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 { }

Then in service-booking-details.tsI do 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');
  }
}

Then in the template, service-booking-detail.htmlI try to use the channel from angular2 -moment :

<ion-content>

    <ion-card>
      <ion-card-content>
         <p>{{ service.data | amDateFormat:'LL' }}</p>
      </ion-card-content>
    </ion-card>

</ion-content>

Then it generates the error "Template analysis errors: cannot find amDateFormat handset."

How to import MomentModule so that I can use it in templates without errors?

0
source share
2 answers

I managed to get this work by importing it into a specific * .module.ts file.

+3
source

MomentModule app.module.ts , , .

0

Source: https://habr.com/ru/post/1649738/


All Articles