gpt4 book ai didi

javascript - 解析中的 AngularJS 注入(inject)错误

转载 作者:行者123 更新时间:2023-12-01 03:02:09 25 4
gpt4 key购买 nike

我正在尝试将用户个人资料元数据作为 promise 放入解析中,然后另一个 promise 使用该元数据根据用户个人资料中的值获取信息。

myApp.config( function myAppConfig ( $routeProvider, authProvider, $httpProvider, $locationProvider, jwtInterceptorProvider) {

$routeProvider.when('/wapmap', {
templateUrl: 'wap_tools/wap_map.html',
controller: 'wapMapClr',
resolve: {
mapres: function(profilePromise, service2) {
profilePromise.then(function(profile) {
var viewerId = profile.app_metadata.viewers[1].viewerId;
return service2.getPromise(viewerId)
})
.then(function(response2) {
makelayerGroup(response2);
mapView(response2);
hasPhotos = response2.vwrSettings[0].photos;
return
})
})
}
},
requiresLogin: true
});

这是 authProvider。它也包含在配置中。

          authProvider.init({
domain: 'someapp.eu.auth0.com',
clientID: 'abcdsefghqwert12345',
callbackURL: location.href,
//URL when not logged in
loginUrl: '/Login'

});


authProvider.on('loginSuccess', function($rootScope, $location, profilePromise, idToken, store, auth, userService) {
console.log("Login Success");
profilePromise.then(function(profile) {

userService.setUser(auth.profile);

store.set('profile', profile);
store.set('token', idToken);
$location.path('/wapmap');
});
$rootScope.loggedIn = auth.isAuthenticated;
$location.path('/wapmap');
});

这会引发以下错误:

     [$injector:unpr] Unknown provider: profilePromiseProvider <- profilePromise <- mapres
http://errors.angularjs.org/1.5.8/$injector/unpr?p0=profilePromiseProvider%20%3C-%20profilePromise%20%3C-%20mapres
at angular.js:68
at angular.js:4511
at Object.getService [as get] (angular.js:4664)
at angular.js:4516
at getService (angular.js:4664)
at injectionArgs (angular.js:4688)
at Object.invoke (angular.js:4710)
at angular-route.min.js:10
at Object.forEach (angular.js:335)
at angular-route.min.js:10

所以这看起来像是一个注入(inject)错误 - 如何将 profilePromise 数据获取到解析中?

最佳答案

error告诉你:

Unknown provider: profilePromiseProvider <- profilePromise <- mapres

确保您正确定义了 profilePromise 服务/工厂并已加载

关于javascript - 解析中的 AngularJS 注入(inject)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46388886/

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