IdleProvider.windowInterrupt 不是函数

IdleProvider.windowInterrupt is not a function

我正在尝试在我的 devbox 上的 node.js 中实现 ng-Idle 的最基本可能实现。为此,我采取了the minimal sample shown at this link, and have installed it in what was a working minimal installation of node.js, which I implemented using the instructions which I have documented at a file sharing site at this link。我对工作最小 node.js 应用程序所做的就是进入一个极简工作应用程序,

1.) Tyoe bower install ng-idle 在客户端应用程序的根文件夹中
2.) 注释掉所有旧的 index.html
3.) 将下面的代码从上面的 link 粘贴到 index.html,只将 url link 更改为 angular.js 并将 angular-idle.min.js 更改为项目中这些文件的实际相对路径。 (我确认 link 都指向实际的 js 库。
4.) 在应用程序所在的客户端文件夹的根目录中键入 grunt serve

上述步骤在网络浏览器中启动了应用程序,但出现以下编译错误:

Error: [$injector:modulerr] Failed to instantiate module demo due to:
IdleProvider.windowInterrupt is not a function
@http://localhost:9000/:122:9  

如果有人对重现这个简单问题的完整工作应用程序感兴趣,我将其放在 a tar ball and posted it to a file sharing site, which you can download by clicking on this link 中。

需要采取哪些具体步骤来解决此错误,以便 ng-idle 可以 运行 在 node.js 的基本安装中?

这里是index.html

<html ng-app="demo">
  <head>
    <title title>NgIdle Sample</title>
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/ng-idle/angular-idle.min.js"></script>

   <script type="text/javascript">
      var app = angular.module('demo', ['ngIdle']);
      app
      .controller('EventsCtrl', function($scope, Idle) {
        $scope.events = [];
        $scope.idle = 5;
        $scope.timeout = 5;
        $scope.$on('IdleStart', function() {
          addEvent({event: 'IdleStart', date: new Date()});
        });
        $scope.$on('IdleEnd', function() {
          addEvent({event: 'IdleEnd', date: new Date()});
        });
        $scope.$on('IdleWarn', function(e, countdown) {
          addEvent({event: 'IdleWarn', date: new Date(), countdown: countdown});
        });
        $scope.$on('IdleTimeout', function() {
          addEvent({event: 'IdleTimeout', date: new Date()});
        });
        $scope.$on('Keepalive', function() {
          addEvent({event: 'Keepalive', date: new Date()});
        });
        function addEvent(evt) {
          $scope.$evalAsync(function() {
            $scope.events.push(evt);
          })
        }
        $scope.reset = function() {
          Idle.watch();
        }
        $scope.$watch('idle', function(value) {
          if (value !== null) Idle.setIdle(value);
        });
        $scope.$watch('timeout', function(value) {
          if (value !== null) Idle.setTimeout(value);
        });
      })
      .config(function(IdleProvider, KeepaliveProvider) {
        KeepaliveProvider.interval(10);
        IdleProvider.windowInterrupt('focus');
      })
      .run(function($rootScope, Idle, $log, Keepalive){
        Idle.watch();
        $log.debug('app started.');
      });
    </script>
  </head>
  <body ng-controller="EventsCtrl">
    <div idle-countdown="countdown">
      <h1>Idle and Keepalive events</h1>
      <button type="button" ng-click="reset()">Reset manually</button>
      <ul>
        <li ng-repeat="event in events">{{event}}</li>
      </ul>

      <div idle-countdown="countdown">
        Timeout in {{countdown}} seconds.
      </div>

      <div>
        Change idle value <input type="number" ng-model="idle" />
      </div>
      <div>
        Change timeout value <input type="number" ng-model="timeout" />
      </div>
    </div>
  </body>
</html>

很抱歉。该 repo 使用 git-flow 源代码控制技术,因此 develop b运行ch 是未发布工作的位置,master 代表发布 b运行ch .您正在查看的 index.html 包含一个示例,说明如何使用已添加但尚未正式发布的功能。

我将继续发布待定功能,但与此同时您可以删除 IdleProvider.windowInterrupt 行,因为它在版本 1.1.1 中不可用。发行版中的样本 index.html 位于 master.

我 运行 你的示例删除了该行并且它按预期工作。