I have the following date picker:
<input kendo-date-picker ng-model="incident.dateOfIncident" required k-format="'{{dateFormat}}'" k-max="today" />
The dateFormat is set to "dd-MMM-yyyy". When I display the value of {{incident.dateOfIncident}} it is showing as:
"2016-03-09T05:00:00.000Z"
but the date picker is blank. Why? and how do I get it to display the date in the dateFormat?
I have read on a different post about parseFormats but I cant seem to get it to work. If I am in fact supposed to use parseFormats what format would I use?
5 Answers, 1 is accepted
The AngularJS template will not be evaluated before widget's initialization. Hence, during initialization process the format is still not defined, which will result in incorrect behavior.
You can find more details about the case here: The best solution in this case will be to use a k-options with predefined options that is coming from the model scope.
Regards,
Georgi Krustev
Telerik
That doesnt seem to work unless I am doing something wrong. Here is what I have:
<
input
kendo-date-picker
ng-model
=
"incident.dateOfIncident"
k-options
=
"incidentDateOptions"
required />
and in the controller:
$scope.incidentDateOptions = {
format:
"dd-MMM-yyyy"
,
max:
new
Date()
};
I prepared a simple Dojo demo showing how to define the format option of the widget: Could you modify the demo showing the erroneous behavior?
Regards,
Georgi Krustev
Telerik
http://dojo.telerik.com/eXOJU/3
Essentially all I did was replace your $scope.dateString = "05-Apr-2016"; with $scope.dateString = "2016-04-13T04:00:00.000Z"; which is how the date is received from the webapi as indicated in the original post. With this date format nothing is appearing in the date picker.l
Probably, I am missing something, but the widget works as expected on my end: If the problem still persists, I would suggest you set the parseFormats option, ensuring that the provided date string can be parsed correctly:
Regards,
Georgi Krustev
Telerik