Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 主日历未在模式中反映日期_Javascript_Angular_Angular5_Primeng - Fatal编程技术网

Javascript 主日历未在模式中反映日期

Javascript 主日历未在模式中反映日期,javascript,angular,angular5,primeng,Javascript,Angular,Angular5,Primeng,我使用Priming Calendar控件可以选择和存储日期,但当我从数据库中获取日期并尝试通过更新模式来设置日期时。我得到以下错误: 我试过各种形式的约会2018年5月17日16:00、“2018年5月17日”、“1526572848”等 我还尝试将模态属性bidsinstalled的数据类型从更改为string、date、number。同样的问题。由于我出错,我不仅不能设置日期,而且日历也不能工作 我在这里遗漏了什么?启动日历接受日期对象。因此,您必须将日期字符串转换为JS日期对象。例如:

我使用Priming Calendar控件可以选择和存储日期,但当我从数据库中获取日期并尝试通过更新模式来设置日期时。我得到以下错误:

我试过各种形式的约会2018年5月17日16:00、“2018年5月17日”、“1526572848”等

我还尝试将模态属性
bidsinstalled的数据类型从
更改为string、date、number。同样的问题。由于我出错,我不仅不能设置日期,而且日历也不能工作


我在这里遗漏了什么?

启动日历接受日期对象。因此,您必须将日期字符串转换为JS日期对象。例如:

new Date('17/05/2018');

然后将其分配给您的模型。

对于启动日历,您需要使用JavaScript日期对象并正确执行实例化。例如,使用新日期('mm/dd/yyyy')(请参阅和)

模板:

 this.bin.BIDInstalledFrom='17/05/2018'
;// I have hardcoded the date in component for the ease of development
<p-calendar [(ngModel)]="bin.bidinstalledfrom" 
            [showTime]="true"
            dateFormat="dd/mm/yy">
</p-calendar>

你可以在这里找到一个有效的演示:

就像我说的,我已经试过日期模型了。我也试过你提到的。同样的问题。你能分享你的转换部分吗。好让我看看。Stackblitz示例可能是。
<p-calendar [(ngModel)]="bin.bidinstalledfrom" 
            [showTime]="true"
            dateFormat="dd/mm/yy">
</p-calendar>
this.bin.bidinstalledfrom = new Date('05/17/2018');