Hello guys I'm trying to make a minimum Date value in a Form. I'm using angular and for some reason that doesn't work I'll post my code:
Component:
minDate: Date;
constructor(private auth: AuthService, private dataService: DataService, private fb: FormBuilder, private router: Router, private matService: MatService) {
this.dataService.getCompanyCouponResult(this.dataService.CouponIdForEdit).subscribe(res => {
this.coupon = res;
this.minDate = this.coupon.startDate;
console.log(this.minDate);
})
Output:
edit-coupon.component.ts:28 2014-02-13T22:00:00.000+0000
html:
New end date:</p>
<input type="date" formControlName="couponEndDate" min="{{minDate}}" >
now I do get the date, and I'm able to see it in console, but for some reason that doesn't apply on the "min" of couponEndDate. any solution?
You need to use pipes in it. Try with this:
<input type="date" formControlName="couponEndDate" min="{{todate | date:'yyyy-MM-dd'}}">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With