ios - Angular2 DatePipe 在 ios 中不工作

标签 ios angular nativescript

我尝试添加 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/

相关文章:

javascript - 有一个可变的 templateUrl

android - 有没有简单的方法可以在 NativeScript/Angular 中为 IOS 和 Android 创建后台任务?

webview - NativeScript:如何禁用 WebView 中的缩放控件?

登录注册首页的IOS最佳实践

ios - Facebook 登录和支付服务的建议

javascript - 在 Angular4 中对输入字段实现多重验证时出错

javascript - Nativescript:逻辑控制sideDrawer

ios - 未通过网络应用程序从 Sinch 收到推送通知

ios - 在 Xcode 7 中为所有 iPhone 设备准确设置 Assets

angular - 为什么给@Input 一个类型会破坏代码?