AngularJS KendoUI DatePicker模型没有绑定

时间:2015-10-14 15:28:45

标签: angularjs kendo-ui datepicker

我想将今日日期绑定到模型和Kendo UI Datepicker并保持同步,但它不起作用...我的DatePicker永远不会在控件上显示模型值。

这是我的代码Angular:

vm.startDateOptions = {
    parseFormats: ["YYYY-MM-DD"]
};

vm.searchInfos = {
    startDate: moment(new Date()).format('YYYY-M-D') 
    // Giving 2015-10-14 for today
}

Html:

<input onkeydown="return false;" id="start" kendo-date-picker 
    k-options="vm.startDateOptions"
    k-ng-model="vm.searchInfos.start" 
    style="width: 100%;"  />

1 个答案:

答案 0 :(得分:0)

如果您想使用值在html中显示它,您可以使用类似

的内容
<h4>Select date:</h4>
        <input 
         kendo-date-time-picker
         k-options="monthSelectorOptions"             
         data-k-ng-model="dateObject"
         data-ng-model="dateString.startDate" 
         style="width: 100%;" />

var startDate = new Date();

      $scope.monthSelectorOptions = {
        value: startDate,
        startDate: startDate,
        format: "dd/MM/yyyy h:mm tt",
        parseFormats: ['ddd MMM dd yyyy'],
        animation: {
            close: {
                effects: "fadeOut zoom:out",
                duration: 300
            },
            open: {
                effects: "fadeIn zoom:in",
                duration: 300
            }
        },
        culture: "de-DE",
      };

And here is complete solution