Reputation: 4014
I'm having an [$injector:unpr]
error in my AngularJS
application.
I've looked at the link which the error provides me with in order to fix the problem, sadly it didn't change anything. So I was hoping you guys might be able to see what I have done wrong.
First the error from my browser console
Error: [$injector:unpr] http://errors.angularjs.org/1.4.7/$injector/unpr?p0=configProvider%20%3C-%20config%20%3C-%20navController
at Error (native)
at http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:6:416
at http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:40:409
at Object.d [as get] (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:38:394)
at http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:40:483
at d (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:38:394)
at Object.e [as invoke] (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:39:161)
at P.instance (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:80:207)
at K (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:61:190)
at g (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:54:410)
(anonymous function) @ angular.min.js:107
(anonymous function) @ angular.min.js:80
n.$apply @ angular.min.js:133
(anonymous function) @ angular.min.js:20
e @ angular.min.js:39d @ angular.min.js:19
zc @ angular.min.js:20Zd @ angular.min.js:19
(anonymous function) @ angular.min.js:293
a @ angular.min.js:174Hf.c @ angular.min.js:35
Then ofcourse my angular code
var config = {
...
};
var app = angular.module('SimPlannerApp', [
'ui.router',
'ui.bootstrap'
]);
app.filter('capitalize', function () {
...
})
.filter('datetime', function ($filter) {
...
});
app.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
var urlBase = '/' + config.IISProjectName + '/';
$stateProvider
.state('login', {
url: "/login",
templateUrl: urlBase + 'views/login.html',
controller: 'loginController'
})
.state('view', {
url: '/view/:view',
templateUrl: urlBase + 'views/view.html',
controller: 'viewController',
resolve: {
view: function ($stateParams) {
...
}
}
})
.state('404', {
url: '{path:.*}',
templateUrl: urlBase + '/views/404.html',
controller: 'errorController'
});
});
app.factory('sharedProperties', function () {
...
});
app.factory('socketService', function () {
...
});
app.controller('errorController', ['$scope', function ($scope) {
...
}]);
app.controller('loginController', ['$scope', '$location', 'socketService', 'sharedProperties', function ($scope, $location, socketService, sharedProperties) {
...
}]);
app.controller('navController', ['$scope', 'config', 'sharedProperties', function ($scope, config, sharedProperties) {
...
}]);
app.controller('viewController', ['$scope', '$state', '$interval', 'view', 'socketService', function ($scope, $state, $interval, view, socketService) {
...
}]);
Upvotes: 0
Views: 809
Reputation: 21901
Seems like you don't have a provider called config
in order to inject in to the controller as,
app.controller('navController', ['$scope', 'config', 'sharedProperties', function ($scope, config, sharedProperties) {
remove the config
being inject and it will work. as,
app.controller('navController', ['$scope', 'sharedProperties', function ($scope, sharedProperties) {
or you have to define a provider called config
.
If you expecting var config
gonna inject in to the controller, actually its not gonna inject. You need a something provider type to inject like service
, factory
, value
.. .
Upvotes: 1