亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

angular.js - How to use angular $interval to implement start timing and end timing on a button
怪我咯
怪我咯 2017-05-15 17:11:04
0
2
617

My code logic is as follows, I want to implement it:

  1. Click the query button to turn on the timer. The button text changes to Stop Query,

  2. Click to stop query and cancel the schedule

$scope.submitRequest = function () {
    if ($scope.onlyButton == "查詢") {
         $scope.onlyButton = "停止查詢";
            $interval(function()
                {
                    //具體方法
                }
                ,5000);
            }
    else{
         setTimeout(function(){
            $scope.onlyButton = "查詢";
            $interval.cancel(stop);
            },0)
        };
    }
    

But I failed to cancel the timer, please help...

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(2)
淡淡煙草味

LZ’s code can completely make a status mark outside, for example:

var interval;
$scope.startStatus = false;

$scope.submitRequest = function(){

    if( !$scope.startStatus ){
        interval = $interval(...);
    } else {
        $interval.cancel(interval);  
    }
    
    $scope.startStatus = !$scope.startStatus;
    
}

Then use it directly in VIEW like this:

<button ng-bind=" !startStatus ? '查詢' : '停止查詢' "></button>

I think it’s better to write like this~

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