24

I have a Rails/AngularJS app which works fine in local development environment. However, when I deployed this app to Amazon Cloud the AngularJS returns this error in the browser console:

Unknown provider: eProvider <- e

However it works fine on development environment.

I am accesing the below service from one of my javascript files.. for eg:-

userList. storeActorListWithId()

My service is the following:-

 woi.service('userList',['$rootScope', 'userAPI' , 'recoAPI', function($rootScope, userAPI, recoAPI){

    var actorList = [];
    var actorId = "";
    return{
        storeActorListWithId: function(data){
            actorList = [];
            angular.forEach(data,function(actor){
                if(actor.castname)
                {
                    actorList.push({name: actor.castname,id: actor.castid});
                }
            })
        } ,
        getActorListWithId: function(){
            return actorList;
        },
        storeActorId: function(id){
            actorId = id;
        },
        getActorId: function(){
            return actorId;
        }
    }

}]);

My application.js file is as follows.Is it minification safe or not.

 resolve: {
                checkActorId: function($route,$location,$rootScope){
                    var url = $route.current.params.id;
                    var actorName = url.replace(/\-/g, " ").replace(/\~/g, "-").replace(/\$/g, "/");
                    var  actorList = $rootScope.storeActorNameAndId;
                    if($rootScope.storeActorNameAndId){
                        angular.forEach(actorList, function(actor, key){
                            if(actor.name == actorName){
                                $rootScope.actorid = actor.id;
                            }
                        });
                    }
                    else
                    {
                        $location.path("home")
                    }
                }
            }

I have tried many solution(use of DI) given on the website but none of them is helping me. Please Help me..

Thanks in advance

SemperFi
  • 2,358
  • 6
  • 31
  • 51
  • 3
    One of you angular service/directive/controller is not written in minification-safe annotation. – Stewie Dec 16 '13 at 12:45
  • @Stewie I have more than 50 service/directive/controller... how will i know which of the above is giving an error.Please help i am new. – SemperFi Dec 16 '13 at 13:03
  • @Stewie I think I may be getting an error in actor.js file..Have uploaded the file.Can You please check it out and let me know if the code is ok and the minification-safe annotation is satisfied or not. – SemperFi Dec 16 '13 at 13:21
  • @Stewie Thanks for the help.it was indeed minification-safe annotation error. – SemperFi Dec 18 '13 at 07:52

3 Answers3

50

Finally got the solution after hours of research.

There was problem of minification-safe annotation in resolve block. This code was giving the above error.

resolve: {
    setParams: function($rootScope, $route) {
        $rootScope.Programmeid = $route.current.params.programmeid;
        $rootScope.channelid = $route.current.params.channelid;
    }
}

I resolved it by changing the code to this:

resolve: {
    setParams: ['$rootScope', '$route', function($rootScope, $route) {
        $rootScope.Programmeid = $route.current.params.programmeid;
        $rootScope.channelid = $route.current.params.channelid;
    }];
}
dǝɥɔS ʇoıןןƎ
  • 1,674
  • 5
  • 19
  • 42
SemperFi
  • 2,358
  • 6
  • 31
  • 51
  • 3
    Yep. Make sure you apply this pattern to the directive-specific controllers too! – anonymous Oct 13 '14 at 22:39
  • 4
    I use ng-strict-di (https://docs.angularjs.org/api/ng/directive/ngApp) to detect the issue also in development env – Marco C. Jul 17 '17 at 17:15
  • I've been struggling with this issue for a while and this was a perfect solution. I finally been able to fix my code and compress my js files. – nael Nov 15 '17 at 17:34
1

In my case (Rails app), I had to remove the uglifier gem from my Gemfile and then remove the config line in config/environments/production.rb:

config.assets.js_compressor = :uglifier
Dorian
  • 22,759
  • 8
  • 120
  • 116
0

in my case

app.config(function ($stateProvider) {
  $stateProvider
    .state('A', {
      ...,       
    });
});

was changed to

app.config(["$stateProvider", function ($stateProvider) {
  $stateProvider
    .state('A', {
      ...,       
    });
}]);

then minification works

tnusraddinov
  • 660
  • 7
  • 13