当我填充KeepaliveProvider.http(…)时,我正在使用ng-Idle并得到一个错误。在大多数情况下,我使用的代码直接取自这里给出的示例http://hackedbychinese.github.io/ng-idle/
这是我的控制器:
function timeoutCtrl(modelData, $scope, Idle, $log, $uibModal) {
var vm = this;
vm.config = {};
(function () {
    vm.config = modelData;
    Idle.watch();
}());
function closeModals() {
    if (vm.warning) {
        vm.warning.close();
        vm.warning = null;
    }
}
$scope.$on('IdleStart', function () {
    $log.debug('IdleStart');
    closeModals();
    vm.warning = $uibModal.open({
        templateUrl: 'timeout-warning-dialog.html',
        controller: 'TimeoutWarningController as timeoutWarning'
    });
});
$scope.$on('IdleEnd', function () {
    $log.debug('IdleEnd');
    closeModals();
});
$scope.$on('IdleTimeout', function () {
    $log.debug('IdleTimeout');
    window.location = '/Session/Timeout/' + vm.config.paxCode;
});}
app.controller('TimeoutController', ['modelData', '$scope', 'Idle', '$log', '$uibModal', timeoutCtrl])
.config(['timeoutData', 'IdleProvider', 'KeepaliveProvider', function (timeoutData, IdleProvider, KeepaliveProvider) {
    IdleProvider.idle(timeoutData.timeoutIdleSeconds);
    IdleProvider.timeout(timeoutData.timeoutWarningSeconds);
    KeepaliveProvider.interval(timeoutData.keepAliveSeconds);
    KeepaliveProvider.http('/api/session/keepalive');
}]);但是在IdleStart打开模式对话框之后,任何鼠标移动都会导致这个错误:enter image description here
$http(...).success不是函数
如果我注释掉设置KeepaliveProvider.http的行(…)则不会发生错误。但是,我的服务器会话也不能保持活动状态。
我已经在谷歌上搜索了allot,大多数例子都没有设置KeepaliveProvider.http(…)。这样做的人也在做和我一样的事情。是否有一些示例中没有的配置是必须完成的?
我使用的是ng-Idle 1.2.2
发布于 2017-03-30 22:25:59
我在这里找到了问题所在。我通过Nuget包获得了AngularJS 1.6.1。因此,.success和.error已被弃用。
但不知何故,我得到了一个旧版本的ng-Ilde版本1.2.2,它使用的是.success。需要下载最新版本的ng-Idle。
https://stackoverflow.com/questions/43103524
复制相似问题