Angular how to set min or max date in input type date ?

How to set date input field’s max date to today ?

Solution : You have to add this your TS file :

export class TestComponent implements OnInit {
// some code...

  currentDate : Date =new Date();

//some code...

}

Then in your template you add :

<input type="date" min="{{currentDate|date:'yyyy-MM-dd'}}" >

Source

Laisser un commentaire