2016-05-17 55 views
1

時產生的錯誤,我創建使用angularjs在當地一切正常,良好的小型項目,並在控制檯中沒有錯誤,但繁重的建設沒有什麼作品,這是錯誤建設項目後:咕嚕構建使用auth0

vendor.ce3c01a3.js:2 Error: [$injector:unpr] Unknown provider: aProvider <-a 
http://errors.angularjs.org/1.5.5/$injector/unpr?p0=aProvider%20%3C-%20a 
at vendor.ce3c01a3.js:1 
at vendor.ce3c01a3.js:1 
at Object.d [as get] (vendor.ce3c01a3.js:1) 
at vendor.ce3c01a3.js:1 
at d (vendor.ce3c01a3.js:1) 
at e (vendor.ce3c01a3.js:1) 
at Object.g [as invoke] (vendor.ce3c01a3.js:1) 
at request (angular-jwt.js:48) 
at g (vendor.ce3c01a3.js:3) 
at vendor.ce3c01a3.js:3(anonymous function) @ vendor.ce3c01a3.js:2 
vendor.ce3c01a3.js:2 Error: [$compile:tpload] Failed to load template:  views/customersReport.html (HTTP status: undefined undefined) 
http://errors.angularjs.org/1.5.5/$compile/tpload? p0=views%2FcustomersReport.html&p1=undefined&p2=undefined 
at vendor.ce3c01a3.js:1 
at i (vendor.ce3c01a3.js:3) 
at g (vendor.ce3c01a3.js:3) 
at vendor.ce3c01a3.js:3 
at o.$eval (vendor.ce3c01a3.js:3) 
at o.$digest (vendor.ce3c01a3.js:3) 
at o.$apply (vendor.ce3c01a3.js:3) 
at vendor.ce3c01a3.js:1 
at Object.g [as invoke] (vendor.ce3c01a3.js:1) 
at g (vendor.ce3c01a3.js:1)(anonymous function) @ vendor.ce3c01a3.js:2 

這裏是我的app.js代碼:

'use strict'; 

var app = angular 
    .module('sampleapp', [ 
    'ngAnimate', 
    'ngMaterial', 
    'ngAria', 
    'ngCookies', 
    'ngMessages', 
    'ngResource', 
    'ngRoute', 
    'ngSanitize', 
    'auth0', 
    'angular-storage', 
    'angular-jwt' 
    ]); 

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

    $routeProvider 
    .when('/createAccount', { 
     controller: 'CreateAccountCtrl', 
     templateUrl: 'views/admin/createAccount.html', 
     pageTitle: 'Homepage', 
     requiresLogin: true 
    }) 
    .when('/login', { 
     controller: 'LoginCtrl', 
     templateUrl: 'views/admin/login.html', 
     pageTitle: 'Login' 
    }) 
    .when('/users', { 
     controller: 'UserManagementCtrl', 
     templateUrl: 'views/admin/usersManagment.html', 
     pageTitle: 'Account' 
    }) 
    .when('/adduser', { 
     controller: 'AccountCtrl', 
     templateUrl: 'views/admin/addUser.html', 
     pageTitle: 'Invite User' 
    }) 
    .when('/account', { 
     controller: 'AccountCtrl', 
     templateUrl: 'views/admin/account.html', 
     pageTitle: 'My account' 
    }) 
    .when('/', { 
     controller: 'CustomersReportCtrl', 
     templateUrl: 'views/customersReport.html', 
     pageTitle: 'Customers Report' 
    }) 
    .when('/customers/:action/:customerId?', { 
     controller: 'CustomersCtrl', 
     templateUrl: 'views/addCustomer.html', 
     pageTitle: '{{action}} Customer' 
    }) 

    .when('/loading', { 
     controller: 'LoadingCtrl', 
     templateUrl: 'views/loading.html' 
    }) 
    .when('/signin', { 
     controller: 'SigninCtrl', 
     templateUrl: 'views/signin.html' 
    }) 
    .when('/myAccount', { 
     templateUrl: 'views/myAccount.html', 
     pageTitle: 'My Account' 

    }) 
    .otherwise({ 
     redirectTo: '/', 
     requiresLogin: true 
    }); 


    authProvider.init({ 
    domain: myDomain, 
    clientID: myClientID, 
    loginUrl: '/login' 
    }); 

    authProvider.on('loginSuccess', function($location, profilePromise, idToken, store, datastoreUser) { 

    console.log("Login Success"); 

    profilePromise.then(function(profile) { 
     store.set('profile', profile); 
     store.set('token', idToken); 

     datastoreUser.getUserIdentity(profile.email).then(function(result) { 
     console.log(result) 
     if (result.data.status == "FOUND") { 
     $location.path("/");  
     }else{ 
     $location.path("/createAccount");  

     } 
     }); 

    }); 

    $location.path("/loading"); 
    }); 

    authProvider.on('loginFailure', function() { 
    alert("Error"); 
    }); 

    jwtInterceptorProvider.tokenGetter = function(store) { 
    return store.get('token'); 
    }; 
    $httpProvider.interceptors.push('jwtInterceptor'); 
}); 


app.config(function($mdThemingProvider) {$mdThemingProvider.theme('default') 
    .primaryPalette('cyan', { 
    'default': '800', 
    'hue-1': '50', 
    'hue-2': '500', 
    'hue-3': '900' 
    }) 
    // If you specify less than all of the keys, it will inherit from the 
    // default shades 
    .accentPalette('grey', { 
    'default': '50', 
    'hue-1' : '200' 
    }); 
}); 


    app.run(function($rootScope,$timeout, auth, store, jwtHelper, $location, datastoreDomain, userSession, datastoreUser, $q) { 

    $rootScope.$on('$locationChangeStart', function() { 

    var token = store.get('token'); 
    if (token) { 
    if (!jwtHelper.isTokenExpired(token)) { 
     if (!auth.isAuthenticated) { 
     auth.authenticate(store.get('profile'), token); 
     getUserIdentity() 
     } 
    } else { 
     // Either show the login page or use the refresh token to get a new idToken 
     $location.path('/login'); 
    } 
    } 

    }); 

function getUserIdentity(){ 

datastoreUser.getUserIdentity(auth.profile.email).then(function(result) { 
    console.log(result) 
    if (result.data.status == "FOUND") { 
    console.log(auth) 
    var domainPromise = datastoreDomain.getById(result.data.identity.domainId).then(function(result){ 
    console.log(result.data) 
    userSession.setDomain(result.data); 
    }); 

    console.log(auth.profile.email) 
    var userPromise = datastoreUser.getById(auth.profile.email).then(function(result){ 

    console.log(result); 
    userSession.setUser(result.data.user); 

    $rootScope.userIdentity = { 
     displayName: result.data.user.displayName, 
     email: result.data.user.email, 
     domainName: result.data.user.domain.name, 
     domainPlan: result.data.user.domain.plan, 
     userRole: result.data.user.role, 
     imageUrl: result.data.user.imageUrl 
    } 

    }); 

    $q.all([domainPromise, userPromise]).then(function(){ 
    $location.path("/"); 
    }) 

}else{ 
    $location.path("/createAccount"); 

    } 
    }); 
} 


}); 

我已經嘗試了一切,卻工程

回答

1

我發現我的問題的解決方案是如此簡單,如果任意子否則得到同樣的問題使用此修復程序來解決未知未知提供程序:縮小後的aProvider。

jwtInterceptorProvider.tokenGetter = ['store', function (store) { 
    return store.get('token'); 
}];