Issue
I have a date input in my project and I would like to set the min/max date to the current date. How can I achieve this in Angular 6?
I've tried to add let date = new Date();
to my ngOnInit and added the max in the HTML file to {{this.date}}
but it does not disable the future dates.
HTML
<input type="date" formControlName="dob" class="form-control" id="dob" max="{{this.date}}">
TS
ngOnInit() {
let date = new Date;
}
Solution
Keeping your way of doing it:
<input type="date" class="form-control" id="dob" max="{{date | date:'yyyy-MM-dd'}}">
You need to pipe the date to follow the input
format.
Answered By - Jojofoulk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.