相关疑难解决方法(0)

AngularJS.调用angular-ui模态时清除$ timeout

$timeout在Modal控制器中有几个表达式

App.controller('ModalCtrl', function ($scope, $timeout) {
    for (var i = 0; i < 10; i++) {
        (function () {
            var timer = $timeout(function () {
                console.log('timer')
            }, 1000);
        })()
    }
})
Run Code Online (Sandbox Code Playgroud)

我需要在调用模态时清除所有计时器:

App.controller('MainCtrl', function ($scope, $modal, $timeout) {
    $scope.showMap = function () {
        var modal = $modal.open({
            templateUrl: 'modalap.html',
            controller: 'modalCtrl',
        })

        modal.result.then(function () { //fires when modal is resolving
        }, function () { //fires when modal is invoking
        });
    } })
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

PS对不起代码格式错误.我不知道为什么,但我不能更好地格式化它.我在这里重复了代码:

timeout angularjs angular-ui

56
推荐指数
1
解决办法
4万
查看次数

如何在Gmap V3中稍微延迟后加载InfoWindow?

我的一个应用程序在Google地图上显示了多个位置标记.如何在短暂延迟后显示InfoWindow?

这是我的脚本:

google.maps.event.addListener(marker, 'mouseover', onMarkerClick);

//create a function that will open an InfoWindow for a marker mouseover
var onMarkerClick = function() {
    var marker = this;
    var latLng = marker.getPosition();
    infowindow.setContent(
        '<h3>Marker position is:</h3>' + latLng.lat() + ', ' + latLng.lng());
    infowindow.open(map, marker);
};
Run Code Online (Sandbox Code Playgroud)

google-maps infowindow google-maps-api-3 google-maps-markers

2
推荐指数
1
解决办法
2857
查看次数

在等待期间取消js

我在加载屏幕上有一些代码,在用户登录前等待五秒钟:

  setTimeout(
    function() {
        $.doPost("http://mysite.com", {
                username: results.rows.item(0).username,
                password: results.rows.item(0).password
            });
  }, 5000);
Run Code Online (Sandbox Code Playgroud)

在页面等待的同时,屏幕上还有一个"退出"按钮,如果点击,则需要发布此帖子.基本上,用户在自动登录之前有五秒钟点击注销.注销按钮有一个onClick,无论我放在该功能中,它继续登录,我怎么能让那个按钮停止$.doPost发生?

javascript jquery timeout

1
推荐指数
1
解决办法
147
查看次数