[英]How to set kendo datepicker date?
I am using kendo datetimepicker but i am not able to get the custom date on html 我正在使用Kendo datetimepicker,但无法在html上获取自定义日期
this is html 这是HTML
<input id="datepicker" ng-model="valid_to" style="width: 100%" kendodate/>
this is directive 这是指令
myApp.directive('kendodate', function() {
return {
restrict: 'EA',
scope: {},
link: function(scope, elem, attrs) {
var start = elem.kendoDatePicker({format: "yyyy/MM/dd"});
}
}
})
this is the controller 这是控制器
myApp.controller('myCtrl',function($scope){
$scope.valid_to = new Date('10-11-2015');
});
how to show this date of controller in html? 如何在html中显示控制器的日期?
In your directive, You need to pass the date defined in your controller. 在您的指令中,您需要传递在控制器中定义的日期。 ie You need to access the
ng-model
in the directive. 即您需要在指令中访问
ng-model
。 Then you can pass its to kendoDatePicker
using 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});
}
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.