【问题标题】:How to set kendo datepicker date?如何设置剑道日期选择器日期?
【发布时间】:2015-11-26 09:54:11
【问题描述】:

我正在使用剑道 datetimepicker,但我无法在 html 上获取自定义日期

这是html

<input id="datepicker" ng-model="valid_to" style="width: 100%" kendodate/>

这是指令

myApp.directive('kendodate', function() {
    return {
        restrict: 'EA',
        scope: {},
        link: function(scope, elem, attrs) {
            var start = elem.kendoDatePicker({format: "yyyy/MM/dd"});

        }
    }
})

这是控制器

myApp.controller('myCtrl',function($scope){
   $scope.valid_to = new Date('10-11-2015');
});

如何在html中显示这个控制器的日期?

【问题讨论】:

  • 指令中的日期无效!
  • 更新了答案。看看吧。

标签: angularjs kendo-ui datepicker


【解决方案1】:

在您的指令中,您需要传递控制器中定义的日期。即您需要访问指令中的ng-model。然后您可以使用 value config 将其传递给kendoDatePicker

myApp.directive('kendodate', function() {
    return {
        require : 'ngModel',
        restrict: 'EA',
        scope: {},
        link: function(scope, elem, attrs, ngModelCtrl) {
            if (!ngModelCtrl || ngModelCtrl.$modelValue) return;
            var start = elem.kendoDatePicker({format: "yyyy/MM/dd", value : ngModelCtrl.$modelValue});    
        }
    }
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-19
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多