Reputation: 4997
I have the following controller in my app, which works fine on my machine. When I push to production and the code is minified, I get the following error: Error: [$injector:unpr] Unknown provider: eProvider <- e <- debounce
. I'm struggling to debug this error. Almost every post I've found on the topic suggests that the problem is with my dependency injection, however I don't think that applies to my case.
var app = angular.module('myApp', ['ngAnimate','ui.bootstrap', 'ngFileUpload', 'rt.debounce']);
app.controller('SocialMediaCtrl', ['$scope', '$rootScope', '$http', '$timeout', '$location', '$q', '$compile', 'socialMediaAPI', 'inspirationsAPI', 'debounce', 'modal', function($scope, $rootScope, $http, $timeout, $location, $q, $compile, socialMediaAPI, inspirationsAPI, debounce, modal) {
$scope.form = {};
$scope.newPost = {
token: $scope.token,
post: $scope.post,
posts: {
twitter: null,
facebook: null,
linkedin: null
},
attachment_url: $scope.attachment_url,
media_url: $scope.media_url,
services: {
twitter: $scope.twitter,
facebook: $scope.facebook,
linkedin: $scope.linkedin
}
};
function getTweetLength(post) {
$scope.tweetLength = post ? 140 - twttr.txt.getTweetLength(post) : 0;
if($scope.tweetLength < 0) {
$scope.tweetLengthValidation = true;
} else {
$scope.tweetLengthValidation = false;
};
};
function getLinkedInPostLength(post) {
var url = twttr.txt.extractUrls(post)[0];
if(post && url) {
$scope.linkedInPostLength = 256 - post.length + url.length;
} else if (post && !url) {
$scope.linkedInPostLength = 256 - post.length;
} else {
$scope.linkedInPostLength = 0;
};
if($scope.linkedInPostLength < 0) {
$scope.linkedInPostLengthValidation = true;
} else {
$scope.linkedInPostLengthValidation = false;
};
};
var getLengthValidations = debounce(10, function(evt){
getTweetLength($(evt.target).val());
getLinkedInPostLength($(evt.target).val());
if($scope.newPost.services.twitter) {
$scope.maxLength = 140;
} else if ($scope.newPost.services.linkedin) {
$scope.maxLength = 256;
} else {
$scope.maxLength = 1000;
};
});
$('textarea').on('keyup keydown cut paste', function(e){
getLengthValidations(e);
})
}]);
Note: The full controller is over 200 lines long, so I've omitted irrelevant parts for brevity.
Upvotes: 1
Views: 1854
Reputation: 165065
The error message seems to be indicating that the debounce
provider instance is requiring the e
provider instance. The problem is most likely not in your controller code but in the code defining the debounce
factory / service / etc. My guess is it does not have the DI array defined.
Going out on a limb, I'd say you're using
bower_components/angular-debounce/src/debounce.js
(no DI)
instead of
bower_components/angular-debounce/dist/angular-debounce.js
(has DI)
Upvotes: 2