2015-10-14 63 views
0

我在我的应用程序中有以下控制器,该控制器在我的机器上正常工作。当我推动生产并缩小代码时,出现以下错误:Error: [$injector:unpr] Unknown provider: eProvider <- e <- debounce。我正在努力调试这个错误。几乎我在这个主题上发现的每篇文章都表明问题出在我的依赖注入上,但我认为这不适用于我的情况。

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); 
    }) 
}]); 

注意:完整的控制器超过200行,所以为了简洁起见我省略了不相关的部分。

+0

您是否尝试过更换你可以使用非缩小文件来缩小你的debounce(可能还有其他的文件),看它是否实际上是引入了错误的缩小版本?我看到一些图书馆没有被缩小(或者引入错误),因为一些特殊的人物与缩小机构不配合。 –

回答

1

错误消息似乎表明debounce提供程序实例需要提供商实例e。问题很可能不在您的控制器代码中,而是在定义debounce工厂/服务等的代码中。我猜测它没有定义DI数组。

的肢体走出去,我说你正在使用

bower_components/angular-debounce/src/debounce.js(无DI)

,而不是

bower_components/angular-debounce/dist/angular-debounce.js(已DI)

+0

钉在头上。我认为这个错误是指向我的控制器中的去抖功能,但显然不是。 – ACIDSTEALTH

相关问题