Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Obfuscation

I am trying to obfuscate my angularjs app and it is breaking. I am aware that this is an issue with the framework and they have tried to remedy it via the $inject method.

http://docs.angularjs.org/tutorial/step_05 See the "Note on Minification" section.

To resolve this they recommend doing YourController.$inject = ['$scope', '$http'];

I went ahead and did that to match my application like so:

AventosController.$inject = ['$scope','$http','$q','controllerComm'];
VforumController.$inject = ['$scope','$http','$timeout','controllerComm'];

Well, it still isn't working. The error I receive in the console is:

Error: Unknown provider: cProvider <- c <- controllerComm

Anyway to remedy this?

EDIT

controllerComm

app.factory('controllerComm', ['$rootScope', function($rootScope)
{
  var showVforum    = {};
  showVforum.result = false;
  showVforum.prepBroadcast = function(val)
  {
    this.result = val;
    this.broadcastVal();
  }

  showVforum.broadcastVal = function()
  {
    $rootScope.$broadcast('toggleVforum')
  }
  return showVforum;
}]);

EDIT 2 not working after obfuscation

$scope.launchVforum = function()
{
  $scope.installationVideo = ($scope.installationVideo) ? false : true;
  controllerComm.prepBroadcast($scope.installationVideo);
}
like image 630
Ronnie Avatar asked Aug 29 '13 17:08

Ronnie


1 Answers

Try injecting at the controller definition.

app.controller('myCtrlr', ['$scope', '$http', '$q', 'controllerComm', function ($scope, $http, $q, controllerComm) {
    ...
}]); // end myCtrlr

Also is "controllerComm" defined?

like image 99
m.e.conroy Avatar answered Oct 22 '22 04:10

m.e.conroy