我想在方法下设置datepicker-options最小和最大日期

时间:2017-06-12 07:49:17

标签: jquery angularjs datepicker

嘿大家我想设置日期datepicker-options设置最大和最小日期,但我有方法参数的最大和最小日期我如何分配这里是我的代码

<input type="text" placeholder="Salary Date" uib-datepicker-popup="M/d/yyyy" ng-model="form.SalaryDate" is-open="form.opened" required="required" ng-click="popen($event,'opened')" ng-required="true" close-text="Close" datepicker-options="options" class="form-control" />

scope.Edit = function (salary) {
            var salaryDate = new Date(salary.SalaryDate);
            var s_dd = salaryDate.getDate();
            var s_mm = salaryDate.getMonth();
            var s_yy = salaryDate.getFullYear();

            var currentDate = new Date();
            var c_dd = currentDate.getDate();
            var c_mm = currentDate.getMonth();
            var c_yy = currentDate.getFullYear();

            scope.options = {
                minDate: new Date(s_yy, s_mm, s_dd),
                maxDate: new Date(c_yy, c_mm, c_dd)
            };           
        };

但此代码无效。它显示了所有月份。请帮帮我怎样才能解决这个问题

1 个答案:

答案 0 :(得分:0)

我已经通过这种方式修复了问题

<input type="text" placeholder="Salary Date" uib-datepicker-popup="M/d/yyyy" ng-model="form.SalaryDate" is-open="form.opened" required="required" ng-click="popen($event,'opened')" ng-required="true" close-text="Close" datepicker-options="{minDate: minDate, maxDate: maxDate }" class="form-control" />

并设置minDatemaxDate

的范围