Javascript 用Angularjs比较日期
我正在创建的页面中使用Javascript 用Angularjs比较日期,javascript,angularjs,Javascript,Angularjs,我正在创建的页面中使用ng show: <td ng-show="week.EndDate > controller.currentDate"> 我的ng show失败无论我是否设置了日期>,您应该将week.EndDate字符串转换为Date对象,或者将比较结果包装在一个函数中,将其转换为日期 ng-show="convertToDate(week.EndDate) > controller.currentDate" 您需要记住的唯一一件事是,如果将week.End
ng show
:
<td ng-show="week.EndDate > controller.currentDate">
我的
ng show
失败无论我是否设置了日期>,您应该将week.EndDate
字符串转换为Date
对象,或者将比较结果包装在一个函数中,将其转换为日期
ng-show="convertToDate(week.EndDate) > controller.currentDate"
您需要记住的唯一一件事是,如果将week.EndDate
永久转换为Date
对象,您可能需要将其转换回所需的格式,例如,当您要将其存储在某处时。currentDate是一个日期对象,很可能是week.Date是一个字符串。
ng-show="convertToDate(week.EndDate) > controller.currentDate"