Azri Jamil
Azri Jamil

Reputation: 2404

Service Injection Error on Liferay Portlet

I have develop a Liferay portlet and using AngularJS for the slient side. By using service injection such as $scope in controller will produce an error of the following:-

Error: Unknown provider: aProvider <- a

Example code:-

<script>
function PayrollCalcCtrl($scope){
}
</script>

If $scope is removed, no error will occur. Any workaround to avoid this situation.

Upvotes: 1

Views: 500

Answers (1)

Stewie
Stewie

Reputation: 60416

Your JS optimizer/obfuscator is messing with your dependencies. Take a look at the DI docs.

You'll want to define your controller in $inject or inline annotation:

var MyController = function(myScope) {
  ...
}
MyController.$inject = ['$scope'];

or

app.controller('MyCtrl', ['$scope', function($scope) {
  ...;
}]);

Upvotes: 2

Related Questions