angular - 错误 toDate() InvalidPipeArgument: '无法转换时间戳.. Firebase
问题描述
当我尝试在我的应用程序中获取它时,例如:
<p>{{ fechaInicio | date }}</p>
得到以下错误:
ERROR 错误:InvalidPipeArgument:'无法将管道'DatePipe'的“时间戳(秒=1553230800,纳秒=0)”转换为日期'
然后我看到添加toDate()
据说可以解决问题:
<p>{{ fechaInicio.toDate() | date }}</p>
这正确显示了日期,但是我收到以下错误:
错误类型错误:无法读取未定义的属性“toDate”
我该如何解决?
解决方案
似乎变量“fechaInicio”是异步加载的。如果是这样,“fechaInicio”在更新之前保持未定义。因此,您可以做的是隐藏 html 段落,直到数据加载到变量中。
尝试以下修改。
<p *ngIf="fechaInicio">{{ fechaInicio.toDate() | date }}</p>
推荐阅读
- sql-server - 如何修复左连接 SQL 查询
- c# - 使用 c# asp.net 4.5 将存储为“图像”数据类型的多个图像从 Sql Server 下载到文件夹
- c# - 如何在 WPF 后面的代码中获取“ContentPresenter”中的数据?
- sql - 正则表达式提取(字符串的左侧部分来自 1 之前的 1 个下划线)
- sql - 如何将 Mysqli NESTED JOIN 查询转换为活动记录
- javascript - socket io 事件触发多次
- reactjs - 基本身份验证登录弹出窗口未显示
- performance - 如何解决“Admob 离线性能问题”?
- c# - 尝试从 QBO API 获取超过 1000 个客户和发票时出现异常
- sql - 填补表格中缺失的天数