【问题标题】:AngularJS KendoUI DatePicker Model not bindingAngularJS KendoUI DatePicker 模型未绑定
【发布时间】:2015-10-14 15:28:44
【问题描述】:

我想将 Today 日期绑定到模型和 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%;"  />

【问题讨论】:

  • 也许你在这里犯了一个错误k-ng-model="vm.searchInfos.start"。您应该使用startDate 而不是start
  • arg.... 这么多时间试图理解这样的错误的问题.... thx

标签: angularjs kendo-ui datepicker


【解决方案1】:

如果你想使用值在你的 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-03
    • 2017-05-15
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多