Javascript angularjs筛选器日期,日期格式错误
我有很多视图,每个视图都与使用angularjs的js控制器相关。 我有一张购买表格,其中有:Javascript angularjs筛选器日期,日期格式错误,javascript,angularjs,html,Javascript,Angularjs,Html,我有很多视图,每个视图都与使用angularjs的js控制器相关。 我有一张购买表格,其中有: <input type="date" ng-model="currentDate"> 我在所有表单中都使用了该方法,工作正常,但在购买表单中,日期没有设置为今天,在控制台中,页面给了我: angular.js:12450Error: [ngModel:datefmt] http://errors.angularjs.org/1.4.6/ngModel/datefmt?p0=2017-01
<input type="date" ng-model="currentDate">
我在所有表单中都使用了该方法,工作正常,但在购买表单中,日期没有设置为今天,在控制台中,页面给了我:
angular.js:12450Error: [ngModel:datefmt] http://errors.angularjs.org/1.4.6/ngModel/datefmt?p0=2017-01-24
at angular.js:38
at Array.<anonymous> (angular.js:21769)
at Object.<anonymous> (angular.js:25349)
at n.$digest (angular.js:15751)
at n.$apply (angular.js:16030)
at angular.js:1660
at Object.e [as invoke] (angular.js:4476)
at d (angular.js:1658)
at yc (angular.js:1678)
at Xd (angular.js:1572)
angular.js:12450错误:[ngModel:datefmt]http://errors.angularjs.org/1.4.6/ngModel/datefmt?p0=2017-01-24
在角上。js:38
在阵列上。(angular.js:21769)
反对。(见js:25349)
n.$digest(angular.js:15751)
在n.$apply(angular.js:16030)
在angular.js:1660
在Object.e[as invoke](angular.js:4476)
在d处(angular.js:1658)
在yc(angular.js:1678)
在Xd处(angular.js:1572)
我不明白问题出在哪里。我检查了注射器($filter),检查了ng型号,如果是重复的,什么也没有。有什么想法吗
所有与日期相关的输入(如)都要求模型
必须是日期对象。如果模型是其他的,则此错误将被忽略
扔
这是在提供的错误url中找到的解释
$scope.currentDate = new Date();
这应该对你有用。您提供了格式化的日期字符串作为输入,这是不需要的
所有与日期相关的输入(如)都要求模型
必须是日期对象。如果模型是其他的,则此错误将被忽略
扔
这是在提供的错误url中找到的解释
$scope.currentDate = new Date();
这应该对你有用。您提供了格式化的日期字符串作为输入,这是不需要的。如果您检查错误链接(),它实际上会给出错误的原因:
模型不是日期对象。
。因此,$scope.currentDate
是一个字符串,而不是一个日期-->出现错误是的,我检查了链接,定义了一个包含日期的变量,问题出在哪里?您的变量不是日期,而是一个字符串。只需执行$scope.currentDate=new Date()
为什么不使用Fissio之类的工具,正在工作,非常感谢如果您检查错误链接(),它实际上会告诉您错误的原因:模型不是日期对象
。因此,$scope.currentDate
是一个字符串,而不是一个日期-->出现错误是的,我检查了链接,定义了一个包含日期的变量,问题出在哪里?您的变量不是日期,而是一个字符串。只需执行$scope.currentDate=new Date()
为什么不做像Fissio这样的工作,非常感谢