【问题标题】:ng-Idle KeepaliveProvider.http .success is not a functionng-Idle KeepaliveProvider.http .success 不是函数
【发布时间】:2017-03-29 20:28:04
【问题描述】:

我正在使用 ng-Idle 并在填充 KeepaliveProvider.http(...) 时出现错误。在大多数情况下,我使用的代码直接取自这里给出的示例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(...) 的行,则不会发生错误。但是我的服务器会话也没有保持活动状态。

我已经在 Google 上搜索过,大多数示例都没有设置 KeepaliveProvider.http(...)。那些做的事情和我做的一样。是否有一些示例中没有的配置必须完成?

我正在使用 ng-Idle 1.2.2

【问题讨论】:

    标签: angularjs modal-dialog ng-idle


    【解决方案1】:

    我在这里发现了问题。我通过 Nuget 包获得了 AngularJS 1.6.1。因此,.success 和 .error 已被弃用。

    但不知何故,我得到了使用 .success 的 ng-Ilde 版本 1.2.2 的旧版本。需要下载最新版的ng-Idle。

    【讨论】:

      猜你喜欢
      • 2017-05-01
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 2016-02-05
      • 1970-01-01
      • 1970-01-01
      • 2019-07-09
      相关资源
      最近更新 更多