3
JS:
var vm = this;
vm.loadNames = function() {
var promise = service.getNames();
promise.then(function (data) {
$scope.names = data.names.data;
$timeout(vm.loadNames, 5000);
});
};
var timer = $timeout(vm.loadNames, 5000);
$scope.canceltime = function(){
$timeout.cancel(timer);
};
HTML:
<button ng-click="canceltime()"></button>
我想停下來點擊按鈕後,$超時。我的代碼不起作用。 感謝您提前給出答案!
謝謝,你幫我 – bafix2203