Reputation: 206
I am trying to set min and max value to angular code here is my code
<input type="date"
class="form-control"
style="width: 30%"
[disabled]="!dateSent"
min="{{dateSent|date:'yyyy-MM-dd'}}"
max="{{todaysdate|date:'yyyy-MM-dd'}}"
#myDate
[value]="dateReceived | date:'yyyy-MM-dd'"
(input)="dateReceived=$event.target.value" />
and the value of datesent and todaydate is same
dateSent=1527445800000 and todaysdate=1527445800000 can any one help me and the out put is like this
thank you for your time and consideration
Upvotes: 1
Views: 8823
Reputation: 18657
You have to take new Date(dateReceived)
Component:
import { Component,OnInit} from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
dateSent;
dateReceived;
todaysdate;
ngOnInit(){
this.dateSent="1527445800000"
this.todaysdate="1527445800000"
}
}
HTML:
<input type="date"
class="form-control"
style="width: 30%"
[disabled]="!dateSent"
min="{{dateSent|date:'yyyy-MM-dd'}}"
max="{{todaysdate|date:'yyyy-MM-dd'}}"
#myDate
[value]="dateReceived | date:'yyyy-MM-dd'"
(input)="dateReceived=$event.target.value" />
Upvotes: 6