如何验证不为空并跳过行?
How to verify not null and skip row if it is?
我正在尝试比较 2 个日期以便能够在 table 中显示数据。
我正在执行以下操作:
${this.dateToCompare.getTime()} > ${row.CreateDate.getTime()}
问题是,CreateDate 在某些行上有一个空值,所以上面的方法不起作用。
我也试过这个:
<div ng-if="${row.CreateDate!==null} && ${this.dateToCompare.getTime()} > ${row.CreateDate.getTime()}"
我需要先检查该行是否为空,但即使它为空,它也会在 && 之后继续,当它遇到 dateToCompare.getTime 时,它会抛出语法错误,因为我我在空值上调用 getTime。
是否可以告诉 ng-if 不要 运行 它如果为 null 并跳过该行?
能够解决此问题并能够 运行 getTime() 的最佳方法是什么?
谢谢
我必须创建一个函数:
convToTime(date: Date) {
if (date !== null)
{
this.tDate = new Date(date.toString().substring(0,10));
return this.tDate.getTime();
}
}
并这样称呼它:
${this.convToTime(row.CreateDate)}
现在和需要时一切正常。
我正在尝试比较 2 个日期以便能够在 table 中显示数据。 我正在执行以下操作:
${this.dateToCompare.getTime()} > ${row.CreateDate.getTime()}
问题是,CreateDate 在某些行上有一个空值,所以上面的方法不起作用。
我也试过这个:
<div ng-if="${row.CreateDate!==null} && ${this.dateToCompare.getTime()} > ${row.CreateDate.getTime()}"
我需要先检查该行是否为空,但即使它为空,它也会在 && 之后继续,当它遇到 dateToCompare.getTime 时,它会抛出语法错误,因为我我在空值上调用 getTime。
是否可以告诉 ng-if 不要 运行 它如果为 null 并跳过该行? 能够解决此问题并能够 运行 getTime() 的最佳方法是什么? 谢谢
我必须创建一个函数:
convToTime(date: Date) {
if (date !== null)
{
this.tDate = new Date(date.toString().substring(0,10));
return this.tDate.getTime();
}
}
并这样称呼它:
${this.convToTime(row.CreateDate)}
现在和需要时一切正常。