How to add month to date in angularjs?

时间:2017-08-14 06:07:01

标签: javascript angularjs

Hi I am developing web application in angularjs. I am developing one form and i have one textbox with date picker. I am using 720kb date picket pluggin. https://github.com/720kb/angular-datepicker I want users to allow dates after 1 month. For example if today is august 14 then i want to enable dates only after september 14. I have added moment.js and put

        var date = moment();
        date.add(1, 'months');
        console.log(date);
        $scope.maxdate=date.d;

In html i have date-min-limit="maxdate". How ever this is not going to work. I got date-max-limit="" method from the above mentioned document. May i know what i am doing wring in the above code? Can someone help me to fix this? Thank you.

2 个答案:

答案 0 :(得分:2)

日期分钟极限=""期望字符串版本的短日期

在您的控制器中

$scope.maxdate = moment().add(1, 'M').format('MM/DD/YYYY');  

在你的HTML中

date-min-limit="maxdate"

答案 1 :(得分:0)

如果您使用bootstrap,则可以使用此插件https://github.com/uxsolutions/bootstrap-datepicker

在其示例demos中,您可以设置开始日期。