Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-Kendo Date Format Behavior

Hello All,

I am running into some problems when using the Kendo-UI date picker in my angular application. Any help would be greatly appreciated.

Thanks in Advance,
Drew

Issue

When using the angular-kendo directive for the date picker along with a date format a date object put into the model. The desired behavior is to store a string in the model as formatted by the options.

Javascript Versions

Angular-Kendo 0.5.2 2013-07-26

AngularJS v1.0.5

jQuery jQuery v1.9.1

Snippet from Template

<input type="text" name="publicationDate" ng-model="preview.publicationDate"  kendo-date-picker="dateOptions" k-options="dateOptions" />

Date Options

$scope.dateOptions = {
    format: "yyyy-MM-dd"
};

Output

Date object stored in model: Tue Sep 17 2013 00:00:00 GMT-0400 (EDT)
Desired string to be stored in model: 2013-09-17

Questions

  1. Is there any remedy for this issue?
  2. Am I using the directive correctly?
like image 877
Andrew Wanczowski Avatar asked Sep 17 '13 15:09

Andrew Wanczowski


3 Answers

In Kendo UI 2014 Q2 (2014.2.625), this is fixed by using k-ng-model instead of ng-model.

like image 158
Roel van Lisdonk Avatar answered Nov 13 '22 22:11

Roel van Lisdonk


I think what is going on is that when you are binding through ng-model, kendo is returning the value of

.value()

In your controller, I believe you can do this:

$scope.$watch('preview.publicationDate'), function (val) {
    if (val) {
       $scope.preview.publicatonDate = kendo.toString(val, "yyyy-MM-dd");
    }
});
like image 28
victormejia Avatar answered Nov 13 '22 23:11

victormejia


This code helps to change the kendo-date-time-picker to the desired format

<input kendo-date-time-picker
             k-options="monthSelectorOptions"
             k-format="'dd/MM/yyyy hh:mm tt'" />
like image 3
Nandha kumar Avatar answered Nov 14 '22 00:11

Nandha kumar