且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置默认格式日期的角度引导用户界面

更新时间:2023-11-29 12:10:58

由于日期是JS Date对象,你必须在发送之前将其转换。您可以使用datefilter在发送前手动解析:

Since the date is a JS Date object, you'll have to convert it before sending. You can use the datefilter to parse manually before sending:

var datefilter = $filter('date'),
    formattedDate = datefilter($scope.dt, 'yyyy/MM/dd');

为例参见本普拉克:http://plnkr.co/edit/EJLDpEojoFnf5QfFt4o6?p=$p$pview

唯一的选择,我知道,是创造价值的指令,并在这个例子的,但是这绝对不是简单的日期选择器指令结合起来。

Only alternative I know of, is creating a directive for the value and pushing a function to $parsers like in this example, but that's definitely not easy to combine with the datepicker directive.

我建议继续使用JS Date对象,只是发送给您的API之前换算的数值。

I'd suggest to continue using the Date object in JS, and just convert the value before sending to your API.