gpt4 book ai didi

javascript - AngularJS:需要在弹出标题中显示 "Expired"

转载 作者:行者123 更新时间:2023-12-03 04:12:50 26 4
gpt4 key购买 nike

我的用户界面中有一个时钟,当我将鼠标悬停在其中时,我会看到一个日期。过期时,我应该只看到“过期”一词,但我看到的是日期加上“过期”。请查看截图:clock hover expired我分享了。

我正在与您分享执行此操作的代码,并且我确信我在那里犯了一个错误:

$scope.getBannerScheduledTitle = function(banner) {

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

var banner_from = null;
var banner_to = null;

if(banner.from){
var pFromDate = new Date(banner.from);

if($scope.countrycode == "US")
banner_from = (pFromDate.getMonth()+1) + "/" + pFromDate.getDate() + "/" + pFromDate.getFullYear();
else
banner_from = pFromDate.getDate() + "/" + (pFromDate.getMonth()+1) + "/" + pFromDate.getFullYear();
}
if(banner.to){
var pToDate = new Date(banner.to);

if($scope.countrycode == "US")
banner_to = (pToDate.getMonth()+1) + "/" + pToDate.getDate() + "/" + pToDate.getFullYear();
else
banner_to = pToDate.getDate() + "/" + (pToDate.getMonth()+1) + "/" + pToDate.getFullYear();
}
if(dd<10) {
dd='0'+dd
}

if(mm<10) {
mm='0'+mm
}

today = dd+'/'+mm+'/'+yyyy;

var title = "";
if (banner.from && banner.to == null)
title += "from " + banner_from + " to " + " ... ";
if (banner.to && banner.from == null)
title += "from " + today + " to " + banner_to;
if (banner.to && banner.from)
title += "from " + banner_from + " to " + banner_to;
if (banner.expired === true)
title += "Expired";

return title;
}

最佳答案

嗯我认为你只需要改变这个:

 (...)  if (banner.expired === true)
title += "Expired";

return title;

致:

   if (banner.expired === true)
title = "Expired";

return title;

告诉我。

关于javascript - AngularJS:需要在弹出标题中显示 "Expired",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44259792/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com