gpt4 book ai didi

javascript - 如何在angular js APP的config.js中正确注入(inject)adalprovier

转载 作者:行者123 更新时间:2023-11-29 21:46:42 25 4
gpt4 key购买 nike

我有如下一段代码

应用程序.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
])
})();

和config.js

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,

但是我得到了这个巨大的异常:

> Error: [$injector:modulerr]
> http://errors.angularjs.org/1.3.7/$injector/modulerr?p0=inspinia&p1=%5B%24injector%3Aunpr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.3.7%2F%24injector%2Funpr%3Fp0%3DadalProvider%0AT%2F%3C%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A6%3A416%0AOb%2Fn.%24injector%3C%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A38%3A307%0Ad%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A36%3A308%0Ae%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A37%3A64%0Ad%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A35%3A293%0Ag%2F%3C%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A35%3A425%0As%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A7%3A300%0Ag%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A35%3A202%0AOb%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A38%3A435%0Asc%2Fd%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A17%3A350%0Asc%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A18%3A153%0AJd%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A16%3A483%0A%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A249%3A412%0An.Callbacks%2Fj%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A26855%0An.Callbacks%2Fk.fireWith%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A27673%0A.ready%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A29465%0AI%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A29656%0A%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fapp.js%3A15%3A6%0A
> angular.min.js:6:415 Error: [$injector:modulerr]
> http://errors.angularjs.org/1.3.7/$injector/modulerr?p0=inspinia&p1=%5B%24injector%3Aunpr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.3.7%2F%24injector%2Funpr%3Fp0%3DadalProvider%0AT%2F%3C%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A6%3A416%0AOb%2Fn.%24injector%3C%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A38%3A307%0Ad%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A36%3A308%0Ae%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A37%3A64%0Ad%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A35%3A293%0Ag%2F%3C%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A35%3A425%0As%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A7%3A300%0Ag%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A35%3A202%0AOb%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A38%3A435%0Asc%2Fd%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A17%3A350%0Asc%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A18%3A153%0AJd%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A16%3A483%0A%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fangular%2Fangular.min.js%3A249%3A412%0An.Callbacks%2Fj%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A26855%0An.Callbacks%2Fk.fireWith%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A27673%0A.ready%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A29465%0AI%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fjquery%2Fjquery-2.1.1.min.js%3A2%3A29656%0A%40http%3A%2F%2Flocalhost%3A21425%2Fjs%2Fapp.js%3A15%3A6%0A
> angular.min.js:6:415

我在 config.js 中将它钉在这个 adalProvider) 上,如果我删除它,它会再次开始工作

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

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

最佳答案

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

如果你看this line AdalProvider 用作已注入(inject)数组的依赖项的引用,因为您直接在函数中注入(inject)依赖项,所以该依赖项将是 adalAuthenticationServiceProvider 而不是 adalProvider.

代码

function config($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider, adalAuthenticationServiceProvider)

关于javascript - 如何在angular js APP的config.js中正确注入(inject)adalprovier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30921900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com