2015-10-14 139 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