0

is there a way to use the moment.format method in HTML? I'm currently using the toLocaleDateString method to display an array of dates:

            <ng-template let-event>
                <div>{{event.date.toLocaleDateString('en-US')}} </div>
            </ng-template>

But I would like to use something like:

            <ng-template let-event>
                <div>{{moment(event.date).format('DD.MM.YYYY')}}</div>
            </ng-template>

For now I get the error: "ERROR TypeError: ctx_r11.moment is not a function" even though it's working without issues when using it in the ts file via the console.log

Patrice
  • 19
  • 4

1 Answers1

0

You can using

getDate(dateAsString) {
    if (dateAsString) {
      return new Date(dateAsString);
    }
    return;
  }
{{ getDate(event.date) | date: "dd.MM.yyyy" }}