如何在config.js中为angular js APP正确注入adalprovier

时间:2015-06-18 17:26:41

标签: javascript jquery angularjs

我有以下代码

app.js

BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH
X-WR-CALNAME:test 2
X-WR-TIMEZONE:Europe/Amsterdam
X-APPLE-CALENDAR-COLOR:#FF2968
BEGIN:VEVENT
TRANSP:OPAQUE
DTEND:20150617T193000Z
UID:test@webscoding.nl
DTSTAMP:20150617T183000Z
LOCATION:Olympus 1\n3524 WB Utrecht\nThe Netherlands
DESCRIPTION:Paulien Prent en Danielle Roumen vs. Rosa van Heesch en Lari
 ssa Nijholt
SEQUENCE:0
X-APPLE-TRAVEL-START;ROUTING=CAR;VALUE=URI;X-ADDRESS=Bingerdenallee 1\\n
 6921 JN Duiven\\nNederland;X-TITLE=Home:
TRIGGER:
X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT45M
SUMMARY:[Tennis wedstrijd] DD 17+ A
DTSTART:20150617T183000Z
CREATED:20150616T223112Z
X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=Olympus 1\\n3524 WB Utre
 cht\\nThe Netherlands;X-APPLE-RADIUS=49.91307222863458;X-TITLE=Olympus 1
 :geo:52.063921,5.128511
BEGIN:VALARM
X-WR-ALARMUID:CDABC4A5-8430-48C7-8AF4-4F031DD57C6A
UID:CDABC4A5-8430-48C7-8AF4-4F031DD57C6A
TRIGGER;X-APPLE-RELATED-TRAVEL=-PT30M:-PT1H15M
DESCRIPTION:Event reminder
ACTION:DISPLAY
END:VALARM
END:VEVENT
END:VCALENDAR

和config.js

(function () {
    angular.module('inspinia', [
        'ui.router',                    // Routing
        'oc.lazyLoad',                  // ocLazyLoad
        'ui.bootstrap',                 // Ui Bootstrap
        'pascalprecht.translate',       // Angular Translate
        'ngIdle',                       // Idle timer
        'AdalAngular'                   //ADAL JS Angular
    ])
})();
然而,我得到了这个巨大的例外:

function config($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider, adalProvider) {

    adalProvider.init(
       {
           instance: 'https://login.microsoftonline.com/',
           tenant: 'mysaasapp.onmicrosoft.com',
           clientId: '33e037a7-b1aa-42ab-9693-6c22d01ca338',
           extraQueryParameter: 'nux=1',
           //cacheLocation: 'localStorage', // enable this for IE, as sessionStorage does not work for localhost.
       },
       $httpProvider
       );

    // Configure Idle settings
    IdleProvider.idle(5); // in seconds
    IdleProvider.timeout(120); // in seconds

    $urlRouterProvider.otherwise("/dashboards/dashboard_1");

    $ocLazyLoadProvider.config({
        // Set to true if you want to see what and when is dynamically loaded
        debug: false
    });

    $stateProvider

        .state('dashboards', {
            abstract: true,
            url: "/dashboards",
            templateUrl: "views/common/content.html",
        })
        .state('dashboards.dashboard_1', {
            url: "/dashboard_1",
            templateUrl: "views/dashboard_1.html",
            requireADLogin: true,

我在config.js中将它钉在了adalProvider上,如果我删除它,它会重新开始工作

我的代码基于:https://github.com/AzureADSamples/SinglePageApp-AngularJS-DotNet/blob/master/TodoSPA/App/Scripts/app.js

区别在于,在该示例中,他们在同一个app.js上进行配置

1 个答案:

答案 0 :(得分:2)

AdalProvider不是provider的正确名称,应该是adalAuthenticationServiceProvider

如果你看this line AdalProvider被用作引入数组的依赖项的参考,那么你的函数中直接注入依赖关系就是adalAuthenticationServiceProvider而不是adalProvider而不是function config($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider, adalAuthenticationServiceProvider)

<强>代码

inspect