角度js缩小后出错。错误:[$ injector:unpr]未知提供者:eProvider< - e< - makeErrorsDirective [英] Error after Minification of angular js. Error: [$injector:unpr] Unknown provider: eProvider <- e <- makeErrorsDirective

查看:240
本文介绍了角度js缩小后出错。错误:[$ injector:unpr]未知提供者:eProvider< - e< - makeErrorsDirective的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Gulp来缩小我的整个js文件。一旦缩小,我得到如下错误:

I used Gulp to minify my entire js files. Once minified I got an error like the following:

[$injector:unpr] Unknown provider: eProvider <- e <- makeErrorsDirective.






我的控制器文件中有一个Custom指令。


I had a Custom directive in my controller file.

var myhubdashboardControllers = angular.module('vpdashboardmodule', []);

.directive('mhDashboard', function ($http, authService, apiService) {
    return {
        restrict: 'EA',
        scope: {
            name: '@',
            dash: '@',
            report: '@',
            disname: '@',
            disdesc: '@',
            distot: '@'
        },
        templateUrl: 'views/dashboard/dashboard-direc.html',
        link: function (scope, element, attr) {
            scope.linkChk = scope.name;
            switch (scope.linkChk) {
                case 'Shipped This Week':
                    scope.url = 'erp/JobShipmentList/PostCpsVwShipmentCount';
                    scope.shipstatus = "Departure";
                    scope.period = "ThisWeek";
                    scope.basicfilter = "Open";
                    scope.linkName = "Shipments";
                    scope.linkDesc = "Shipped This Week";
                    break;

})
};

这是我的申请中使用的代码。

This is the code used in my application.

推荐答案

你有一个理由感谢你必须在字符串数组中注入服务和控制器。

There is a reason why you have to inject services and controller in string array.

如果你想给控制器注入范围,你必须使用

if you want to inject scope to controller, you have to use

angular.module('yourApp')
    .controller('yourController',['$scope',function($scope){
    }]);

缩小将更改变量名称,如果在注入服务时不使用该字符串数组或控制器,就像

Minification will change the variable names and if you don't use that array of strings while injecting services or controllers, it will be like

 angular.module('yourApp')
    .controller('yourController',function(e){
    });

因此,angular将无法理解'e'代表什么,因此错误。
永远记住订单也很重要。

So, angular will not be able to understand what 'e' stands for, hence the error. Always remember that the order is also important.

.directive('mhDashboard', ['$http','authService','apiService', function ($http, authService, apiService) {
    return {
        restrict: 'EA',
        scope: {
            name: '@',
            dash: '@',
            report: '@',
            disname: '@',
            disdesc: '@',
            distot: '@'
        },
        templateUrl: 'views/dashboard/dashboard-direc.html',
        link: function (scope, element, attr) {
            scope.linkChk = scope.name;
            switch (scope.linkChk) {
                case 'Shipped This Week':
                    scope.url = 'erp/JobShipmentList/PostCpsVwShipmentCount';
                    scope.shipstatus = "Departure";
                    scope.period = "ThisWeek";
                    scope.basicfilter = "Open";
                    scope.linkName = "Shipments";
                    scope.linkDesc = "Shipped This Week";
                    break;
}
}])

这篇关于角度js缩小后出错。错误:[$ injector:unpr]未知提供者:eProvider&lt; - e&lt; - makeErrorsDirective的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆