在角度剑道日期选择器中将日期值绑定到ng-model [英] Binding date value to ng-model in angular kendo date picker
问题描述
我有一个api,它以"014-08-26T15:10:45.402Z"格式返回日期,我正在使用角度剑道ui.我面临的问题是日期未绑定到剑道日期选择器有人可以帮我吗.
I have an api which return the date in this format "014-08-26T15:10:45.402Z" i am using angular kendo ui .The problem i am facing is the date is not getting bound to the kendo date picker.Could someone help me out .
<input kendo-date-picker ng-model="emp.datestart" k-format="MM/dd/yyyy" />
推荐答案
要使Kendo DatePicker使用字符串日期值模型,您需要:
In order to have the Kendo DatePicker working with a string date value model you need:
1)使用 k-ng-model 而不是ng-model.
1) Use k-ng-model instead of ng-model.
2)告诉小部件将以哪种精确格式解析日期.
2) Tell the widget in which exact format the date will be parsed.
<input kendo-date-picker k-ng-model="emp.datestart" k-options="datePickerOptions" />
然后在AngularJS控制器上,您将指定日期解析格式,例如:
Then at your AngularJS controller you will specify the date parsing format, for example:
$scope.datePickerOptions = {
parseFormats: ["yyyy-MM-ddTHH:mm:ss"]
};
这篇关于在角度剑道日期选择器中将日期值绑定到ng-model的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!