在条件表达式中使用日期管道-Angular 2 [英] Using date pipe in a conditional expression - Angular 2

查看:82
本文介绍了在条件表达式中使用日期管道-Angular 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期望Angular使用date表达式通过日期管道内插日期(如果不为null),但是会出现执行错误.

With the follow expression I'm expecting for Angular to interpolate a date (if not null) through the date pipe, but I get the proceeding error.

{{charge.offenseDate ? charge.offenseDate | date : 'No date'}}

EXCEPTION: Error: Uncaught (in promise): Template parse errors:
Parser Error: Conditional expression {{charge.offenseDate ? charge.offenseDate | date : 'No Date' }} requires all 3 expressions at the end of the expression

这是我所期望的,或者只是... 白日梦:)

Is what I'm expecting possible, or just a...pipe dream :)

推荐答案

只需用()

{{charge.offenseDate ? (charge.offenseDate | date) : 'No date'}}

这篇关于在条件表达式中使用日期管道-Angular 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆