angular.js - ng-repeat的值回处理后再绑定到页面
我想大声告诉你
我想大声告诉你 2017-05-15 17:08:11
0
1
542
<p ng-switch="list.state">
     <p ng-switch-when="0">
         <p class="rob text-center btn-rob" ng-if="list.openTime<=0">
             <p class="content">开抢<br></p>
         </p>
     
         <p class="rob text-center btn-full" ng-disabled="true" ng-if="list.openTime>0">
            <p class="content">即将开标<br><span >这里需要倒计时</span></p>
         </p>
    </p>
    
    <p ng-switch-when="1" class="rob text-center btn-full" ng-click="jump('/invest')" ng-disabled="true">
        <p class="content">满标</p>
     </p>
</p>

上面代码:倒计时 ng-repeat可获取到毫秒差值 list.openTime 需要做成倒计时的字符串显示在 span中,请问应该怎么做?

我想大声告诉你
我想大声告诉你

reply all(1)
阿神

list.openTimeThis variable itself should already exist in the controller. Normally you should have this sentence in your controller

var list = this;

If this list.openTime is just a value sent back by the server and does not need to be sent back to the server, then you can directly operate the period in the controller.

//controller
list.openTime=Math.round(list.openTime);//把时间转化成时间戳
$interval(function () {
    list.openTime -= 1;//每秒减一,在页面把这个格式化成时间格式
}, 1000);
//html
<span>{{list.openTime|date:"HH:mm:ss"}}</span>

If list.openTime is still useful, then clone it to another variable and use another variable to decrement.
Strictly speaking, the decrement function should be put into a variable and canceled when the decrement ends.
That’s probably what it looks like.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template