如何使离子中的不同参数同时起作用

时间:2017-12-26 09:37:12

标签: javascript android ios angular ionic-framework

我有一些事件列表,我希望在其中显示一个事件以" d hh:mm:ss"为每个事件。我已经为一个事件做了这个,但是不能同时为其他事件做。所以任何人都可以帮助我。

我在这里做了什么: -

var COUNT_START = Math.abs(122234/100);
   var count = COUNT_START;
   var playing = true;

  function countdown(){
     displayTime();
     if (count == 0) {
       playing = false;
     } else if (playing) {
       $timeout(countdown, 100);
       count--;
     } else {
       $timeout(countdown, 100);
     }
  }

countdown();

function displayTime() {
  var tenths = count;
  var sec = Math.floor(tenths / 10);
  var hours = Math.floor(sec / 3600);
 // console.dir("hours"+hours);
  sec -= hours * (3600);
  var mins = Math.floor(sec / 60);
  sec -= mins * (60);
  var day = Math.floor(hours / 24);

  if(day > 0)
  {
    hours=hours-day*24;

  }
  if (hours < 1) {

     time = day+'d '+hours+'h:'+LeadingZero(mins)+'m:'+LeadingZero(sec)+'s';


  }
  else {

      time = day+'d '+hours+'h:'+LeadingZero(mins)+'m:'+LeadingZero(sec)+'s';

  }
}

function LeadingZero(Time) {
  return (Time < 10) ? "0" + Time : + Time;
}
console.dir(time);
return time;

0 个答案:

没有答案