【问题标题】:i want to set datepicker-options min and max date under method我想在方法下设置 datepicker-options 最小和最大日期
【发布时间】:2017-11-13 14:41:28
【问题描述】:

大家好,我想设置日期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)
            };           
        };

但此代码不起作用。它显示所有月份。请帮助我如何解决这个问题

【问题讨论】:

    标签: jquery angularjs datepicker


    【解决方案1】:

    我已经通过这种方式解决了问题

    <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的范围

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多