IdleProvider.windowInterrupt不是函数 [英] IdleProvider.windowInterrupt is not a function

查看:484
本文介绍了IdleProvider.windowInterrupt不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得最基本的可能实施的 NG-空闲的的node.js 我的工作devbox。为此,我已采取在此链接显示的最少的样品,和在什么是的node.js ,这是我使用的这是我在文件共享网站已经记录了这个链接说明。我所做的工作的最小的Node.js应用程序是进入一个最低限度的工作程序,

1)Tyoe 凉亭安装NG-空闲中的客户端应用程序结果的根文件夹
2)注释掉所有的旧的 index.html的结果
3)从下面的链接中code粘贴成以上 index.html的,只更改URL链接 angular.js 角idle.min.js 到项目的文件的实际相对路径。 (我证实,这两个链接指向的实际 JS 库。结果
4)键入咕噜在应用程序所在的客户端文件夹的根目录服务

以上步骤展开在Web浏览器的应用程序,但给出了以下的编译错误:

 错误:[$喷油器:modulerr]未能实例由于模块演示:
IdleProvider.windowInterrupt不是函数
@http://本地主机:9000/122:9

如果有人有兴趣,再现这个简单问题的完整的工作程序,我把它放在焦油球和贴到一个文件共享网站,您可以通过点击此链接下载。

的具体步骤所需要的采取解决这个错误,使NG-闲置在node.js中的这一基本安装运行?

下面是 index.html的

 < HTML NG-应用=演示>
  < HEAD>
    <标题标题> NgIdle采样< /标题>
    &所述; SCRIPT SRC =bower_components /角度/ angular.js>&下; /脚本>
    <脚本SRC =bower_components / NG空闲/角idle.min.js>< / SCRIPT>   <脚本类型=文/ JavaScript的>
      VAR应用= angular.module('示范',['ngIdle']);
      应用
      .controller('EventsCtrl',函数($范围,空闲){
        $ scope.events = [];
        $ scope.idle = 5;
        $ scope.timeout = 5;
        $范围。在$('IdleStart',函数(){
          的addEvent({事件:'IdleStart',日期,新的日期()});
        });
        $范围。在$('IdleEnd',函数(){
          的addEvent({事件:'IdleEnd',日期,新的日期()});
        });
        $范围。在$('IdleWarn',函数(即倒数){
          的addEvent({事件:'IdleWarn',日期,新的日期(),倒计时:倒数});
        });
        $范围。在$('的IdleTimeout',函数(){
          的addEvent({事件:'的IdleTimeout',日期,新的日期()});
        });
        $范围。在$('存活',函数(){
          的addEvent({事件:'存活',日期,新的日期()});
        });
        功能的addEvent(EVT){
          $范围。$ evalAsync(函数(){
            $ scope.events.push(EVT);
          })
        }
        $ scope.reset =功能(){
          Idle.watch();
        }
        $范围。$表(空闲,功能(价值){
          如果(价值== NULL!)Idle.setIdle(值);
        });
        $范围。$表(超时,功能(价值){
          如果(价值== NULL!)Idle.setTimeout(值);
        });
      })
      的.config(功能(IdleProvider,KeepaliveProvider){
        KeepaliveProvider.interval(10);
        IdleProvider.windowInterrupt('焦点');
      })
      .RUN(函数($ rootScope,空闲,$日志,存活){
        Idle.watch();
        $ log.debug(应用程序启动。);
      });
    < / SCRIPT>
  < /头>
  <机身NG控制器=EventsCtrl>
    < D​​IV空闲倒计时=倒计时>
      < H1>空闲和存活事件< / H1>
      <按钮式=按钮NG点击=reset()的>手动&LT复位; /按钮>
      < UL>
        <李NG重复=事件事件> {{}事件}< /李>
      < / UL>      < D​​IV空闲倒计时=倒计时>
        超时{{倒计时}}秒。
      < / DIV>      < D​​IV>
        更改idle值<输入类型=数字NG-模式=闲置/>
      < / DIV>
      < D​​IV>
        更改超时值<输入类型=数字NG-模式=超时/>
      < / DIV>
    < / DIV>
  < /身体GT;
< / HTML>


解决方案

对此深感抱歉。这种回购使用混帐流程源代码控制技术,因此制定分支就是未发行工作顺利,而重新presents发布分支。你在看 index.html的包括如何使用添加的一项功能,尚未正式发布的又一个例子。

我会释放挂起功能向前发展,但在此期间,你可以删除 IdleProvider.windowInterrupt 行,因为这不是在1.1.1版本。从发布的范例index.html在

我跑你的榜样与行中删除,并将其按预期工作。

I am trying to get the most basic possible implementation of ng-Idle working in node.js on my devbox. Towards this end, I have taken 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. All I did to the working minimal node.js app was to go into a minimalist working app,

1.) Tyoe bower install ng-idle in the root folder of the client app
2.) Comment out all of the old index.html
3.) Paste the code below from the link above into index.html, and only change the url links to angular.js and angular-idle.min.js to the actual relative paths of those files in the project. (I confirmed that both links point to the actual js libraries.
4.) Type grunt serve in the root of the client folder where the app is located.

The above steps launched the app in a web browser, but gave the following compilation error:

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

If anyone is interested in the complete working app that recreates this simple problem, I put it in a tar ball and posted it to a file sharing site, which you can download by clicking on this link.

What specific steps need to be taken to resolve this error so that ng-idle can run in this basic installation of node.js?

Here is 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>

解决方案

Sorry about that. That repo is using the git-flow source control technique, so the develop branch is where unreleased work goes, and master represents the release branch. The index.html you were looking at includes an example of how to use a feature that was added that hasn't been officially released yet.

I'll move ahead with releasing the pending features, but in the meantime you can remove the IdleProvider.windowInterrupt line, as that's not available in version 1.1.1. The sample index.html from the release is found in master.

I ran your example with that line removed and it works as expected.

这篇关于IdleProvider.windowInterrupt不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆