同一输入类型日期中的角度4最小和最大vlue不起作用 [英] angular 4 min and max vlue in same input type date not working

查看:41
本文介绍了同一输入类型日期中的角度4最小和最大vlue不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将最小和最大值设置为角度代码,这是我的代码

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

并且dateent和todaydate的值相同

and the value of datesent and todaydate is same

dateSent = 1527445800000 和 今天日期= 1527445800000 谁能帮我 而输出就是这样

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

感谢您的时间和考虑

推荐答案

您必须采用new Date(dateReceived)

组件:

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

这是一个有效的演示版本

这篇关于同一输入类型日期中的角度4最小和最大vlue不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆