I created a mini project using angularjs in local everything works good and no errors in console but after building the project with grunt build nothing works and this is the error :
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
Here is my app.js code :
'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");
}
});
}
});
i have tried everything but didn't works
答案 0 :(得分:1)
我发现我的问题的解决方案很简单,如果有其他人得到同样的问题,请使用此修复程序解决未知的未知提供商:缩小后的提供商。
jwtInterceptorProvider.tokenGetter = ['store', function (store) {
return store.get('token');
}];