Error after setting up angular js. Error: [$ injector: unpr] Unknown provider: eProvider <- e <- makeErrorsDirective

I used Gulp to minimize all my js files. After rounding, I got an error similar to the following:

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

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.

+6
source share
5 answers

There is a reason you need to inject services and a controller into an array of strings.

if you want to enter the control area of ​​the controller, you must use

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

Minification , ,

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

, angular , "e", , . , .

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

, gulp -ng-annotate, $stateProvider ngDialog :

$stateProvider
  .state('orders', {
    url: '/orders',
    templateUrl: 'templates/orders.html',
    controller: 'OrdersController as vm',
    resolve: {
      authenticate: function (Auth) {
        return Auth.getAuthResolve();
      }
    }
  });

:

    resolve: {
      authenticate: ['Auth', function (Auth) {
        return Auth.getAuthResolve();
      }]
    }

, , ng-annotate , controller/service/ factory.

+2

Angular .

:

angular.controller("MyCtrl", function ($scope) {...});

$scope - .

:

angular.controller("MyCtrl", ["$scope", function (s) {...}]);

, ( s), "$scope".

: https://docs.angularjs.org/tutorial/step_05#a-note-on-minification .

, , , .

+1
source

angular-ui-router-title.

$titleProvider.documentTitle(function($rootScope) {
    return $rootScope.$title + ' my title';
});

$titleProvider.documentTitle(['$rootScope', function($rootScope) {
    return $rootScope.$title + ' my title';
}]);

the error no longer appears.

0
source

The solution provided by @Render worked for me

-1
source

Source: https://habr.com/ru/post/1626835/


All Articles