在角度剑道日期选择器中将日期值绑定到 ng-model [英] Binding date value to ng-model in angular kendo date picker

查看:20
本文介绍了在角度剑道日期选择器中将日期值绑定到 ng-model的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 api,它以014-08-26T15:10:45.402Z"这种格式返回日期,我使用的是 angular kendo ui.我面临的问题是日期没有绑定到 kendo 日期选择器.谁能帮帮我.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆