IdleProvider.windowInterrupt is not a function
Asked Answered
E

1

0

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>
Emigrant answered 16/2, 2016 at 23:34 Comment(0)
J
1

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.

Jacquejacquelin answered 17/2, 2016 at 8:55 Comment(8)
When I untar the tar, comment out the one line, and then grunt serve, the app shows up in an unformated form in the browser and does not give complete functionality. Can you suggest any other changes to get it to function properly the way your app example works? Here is a link to a gif showing the way that the app looks after just commenting out the one line and typing grunt serve: jumpshare.com/v/JvceCRyu9knZmU8v0oCnEmigrant
@Emigrant Not sure what you mean. The image you provided indicates to me it's working. Maybe you're expecting it to look exactly like the demo... the UI is not a part of the module; the module is not opinionated about UI, you have to wire that stuff up yourself. The demo (hackedbychinese.github.io/ng-idle) shows you how to use it with ui-bootstrap to show a modal.Jacquejacquelin
Thank you. I am trying to hook up the demo code after getting your minimal sample to work, but it is not wiring effectively. Are you going to be available to look at it if I spend 20 minutes tar-ing it up and uploading it now?Emigrant
@Emigrant Sure. It's probably better to take this off StackOverflow and just get in touch with me in the Gitter chatroom for the ng-idle project: gitter.im/HackedByChinese/ng-idleJacquejacquelin
Thank you. I might get a github account to do that going forward, but I would have to think through privacy issues before planning such an account. If I post another OP here with the next step, will you be on here in 20 minutes when it is up?Emigrant
Something came up. It may be longer. Will send message. Thank you VERY MUCH.Emigrant
@Emigrant I'm concerned that SO mods and community members will find it to be an abuse of the rules here, to use posts for really and direct help. Usually they ask you to take it off SO and into an email or chat. If you can't use Gitter or Github, you could post in SO chat (chat.stackoverflow.com/rooms/17/javascript) or email meJacquejacquelin
I am just now reading your comment after posting another OP. If your sensibilities prefer to discuss this in chat, I would be happy to delete the other OP and to discuss it in chat with you out of respect for your sensibilities. However, in the absence of that, this entire site is built on questions like this, which involve hooking up different liibraries in different ways? Here is the link: #35492778Emigrant

© 2022 - 2024 — McMap. All rights reserved.