相同输入类型日期的角度4分钟和最大虚线不起作用

时间:2022-09-27 09:34:21

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和todaydate的价值是一样的

dateSent=1527445800000 and todaysdate=1527445800000 can any one help me and the out put is like this

dateSent = 1527445800000和todaysdate = 1527445800000任何人都可以帮我,输出就是这样的

相同输入类型日期的角度4分钟和最大虚线不起作用

thank you for your time and consideration

感谢您的时间和考虑

1 个解决方案

#1


4  

You have to take new Date(dateReceived)

你必须采取新的日期(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:

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" />

Here is a Working DEMO

这是一份工作演示

#1


4  

You have to take new Date(dateReceived)

你必须采取新的日期(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:

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" />

Here is a Working DEMO

这是一份工作演示