我尝试添加 DatePipe
在我的 Nativescript
+ Angular 2
移动应用程序。它在 Android 模拟器上工作,但在 ios 模拟器上出错。
Error: file:///app/tns_modules/@angular/core/bundles/core.umd.js:9427:77: JS ERROR Error: Error in pages/home/home.component.html:86:29 caused by: Invalid argument '2016-11-15T10:51:07+0300' for pipe 'DatePipe'
我的代码:<Label col="1" [text]="item.datetime | date:'yMMMd'"></Label>
请帮我解决这个问题。
最佳答案
根据 documentation DatePipe
可以像date_expression | date[:format]
其中 expression
是日期对象或数字(自 UTC 纪元以来的毫秒数)或 ISO 字符串,因此请确保您的 item.datetime
值将是日期对象或以毫秒为单位的数字。
关于ios - Angular2 DatePipe 在 ios 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41456922/