Answer the question
In order to leave comments, you need to log in
How to format date in Angular 2?
It is necessary that the date be displayed in the format DD/MM (the variant with the dot DD.MM is allowed). For example, "February 23" should look like this: 23/02 (or 23.02).
To do this, HTML has an editable input with a date:
<inline-editor type="date" [(ngModel)]="product.personBirthDate" (onSave)="saveEditable($event)" name="personBirthDate" size="8"></inline-editor>
import { DatePipe } from '@angular/common';
personBirthDate: number = Date.now();
Answer the question
In order to leave comments, you need to log in
It should be divided [(ngModel)]
into two blocks:
[ngModel] ="product.personBirthDate | date : "dd/MM/yyyy"
, which will display the data, and , to set it. (ngModel) = "personBirthDate=$event"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question