AngularJS:未知提供者:$idleProvider

前端之家收集整理的这篇文章主要介绍了AngularJS:未知提供者:$idleProvider前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
很多其他有类似问题的人,但决议似乎不适用于我的具体问题.

我正在尝试使用ngIdle(https://github.com/HackedByChinese/ng-idle)库,但似乎无法在没有出现此错误的情况下运行它 – 未捕获错误:[$injector:modulerr]无法实例化模块myAuditModule,原因是:错误:[$injector:unpr ]未知提供者:$idleProvider

这是我的模块代码,

(function () {
    app = angular.module("myAuditModule",['ui.bootstrap','ngRoute','ngCookies','ngDragDrop','ngIdle']);

    // configure the routes
    app.config(function ($routeProvider,$idleProvider,$keepaliveProvider) {

        $idleProvider.idleDuration(10 * 60); // 10 minutes idle
        $idleProvider.warningDuration(30); // 30 second warning
        $keepaliveProvider.interval(5 * 60); // 5 minute keep-alive ping

        $routeProvider

             //route for the logging in page
            .when('/',{
                templateUrl: 'Views/Login.html',controller: 'loginController'
            })

    });

    })();

文件包含在我的项目中,并且在网站运行时显示在开发者控制台中 –

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

唯一的依赖是你需要使用1.2或更高的角度,我就是这样.

有任何想法吗?

解决方法

在app.config中将$idleProvider替换为IdleProvider并尝试

app.config(function ($routeProvider,IdleProvider,KeepaliveProvider) {

    IdleProvider.idleDuration(10 * 60); // 10 minutes idle
    IdleProvider.warningDuration(30); // 30 second warning
    KeepaliveProvider.interval(5 * 60); // 5 minute keep-alive ping

    .....
});

还将$keepaliveProvider替换为KeepaliveProvider

猜你在找的Angularjs相关文章