Set min date to current date in angularJS input

前端 未结 5 794
梦如初夏
梦如初夏 2020-12-30 02:59

In AngularJS, how can we set the min attribute of input type=\"date\" to current date (today\'s) ?



        
5条回答
  •  一个人的身影
    2020-12-30 03:41

    Yes you can set a minimum value. According to docs:

    
    

    Arguments

    min (optional) string - Sets the min validation error key if the value entered is less than min. This must be a valid ISO date string (yyyy-MM-dd).

    EDIT To set the field to current date:

    controller:

    function Ctrl($scope)
    {
        $scope.date = new Date();
    }
    

    view:

    
    

    Working example here.

提交回复
热议问题