我正在尝试混淆我的AngularJS应用程序,但是出现了问题。我知道这是框架的问题,他们已经尝试通过$inject方法来解决它。
请参阅“缩小说明”部分,链接:http://docs.angularjs.org/tutorial/step_05 为了解决这个问题,他们建议进行以下操作:
请参阅“缩小说明”部分,链接:http://docs.angularjs.org/tutorial/step_05 为了解决这个问题,他们建议进行以下操作:
YourController.$inject = ['$scope', '$http'];
我已经按照我的应用程序进行了相应修改:AventosController.$inject = ['$scope','$http','$q','controllerComm'];
VforumController.$inject = ['$scope','$http','$timeout','controllerComm'];
嗯,它仍然无法工作。我在控制台中收到的错误是:
Error: Unknown provider: cProvider <- c <- controllerComm
有什么方法可以解决这个问题吗?
编辑
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;
}]);
编辑2混淆后无法工作
$scope.launchVforum = function()
{
$scope.installationVideo = ($scope.installationVideo) ? false : true;
controllerComm.prepBroadcast($scope.installationVideo);
}
app.controller('AventosController',[...]
来定义控制器,而不是像这样定义:function AventosController (..){..}
?目前我是用第一种方式定义的。 - RonniecontrollerComm
做了同样的操作,问题解决了!非常感谢。 - Ronnie