javascriptangularjsng-idle

ng-idle cannot read a property


I'm updating the angular.js vesion but the project is using this depency angular-idle but it keeps telling me "Cannot read property 'idle' of undefined" this is the code.

var smartApp = angular.module("b2bApp", [
    "ngResource",
    "ngRoute",
    "ngCookies",
    "ngIdle",
     ...]);

smartApp.config(["$routeProvider", "$provide","$locationProvider",
    function($routeProvider, $provide, $locationProvider, IdleProvider, KeepaliveProvider) {
    "use strict";

        IdleProvider.idle(20 * 60);
        IdleProvider.timeout(3);
        KeepaliveProvider.interval(2);
      ...}]);

The file is also added in the html file

    <script src="/vendor/ng-idle/angular-idle.js"></script>

I don't know what is happening?


Solution

  • You need to specify all of the providers you want to inject as strings. You've already done this for the first three parameters but not for the last 2.

    ["$routeProvider", "$provide","$locationProvider", "IdleProvider", "KeepaliveProvider",
    function($routeProvider, $provide, $locationProvider, IdleProvider, KeepaliveProvider)...