2015-10-14 105 views
0

我想将Today日期绑定到模型和Kendo UI Datepicker并保持它们同步,但它不起作用...我的DatePicker从不在控件上显示模型值。AngularJS KendoUI DatePicker Model not binding

这里是我的代码角:

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%;" /> 
+0

也许你在这里犯了一个错误'k-ng-model =“vm.searchInfos.start”'。 您应该使用'startDate'而不是'start'。 –

+0

arg ....这么多时间试图了解这样的错误的问题.... thx – Vince

回答

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