Robert Lawson
Robert Lawson

Reputation: 83

Angular JS : Unknown Provider

I am having issues trying to minify my Angular app. The error I am receiving is:

Error: [$injector:unpr] Unknown provider: $scope, dataServiceProvider <- $scope, dataService

My App:

angular.module('Forms', [
'ngRoute',
'Forms.Services',
'Forms.Directives',
'Forms.Controllers'
])

My Service is:

angular.module('Forms.Services', []).
service('dataService', ['$http', function ($http) {
    this.getData = function(callback) {
        $http.get('forms.json').success(callback);
    }
}]);`

My Controller is:

angular.module('Forms.Controllers', []).
controller('FormController', ['$scope, dataService', function ($scope, dataService) {

    dataService.getData(function(results) {
        $scope.data = results;
    });

}])

It is working fine without the Array notation but as you know it will not minify.

Upvotes: 1

Views: 2417

Answers (1)

NOtherDev
NOtherDev

Reputation: 9682

Should be:

controller('FormController', ['$scope', 'dataService', function //...

instead of:

controller('FormController', ['$scope, dataService', function //...

Note that the dependencies are listed as separate strings in the array, not as a single string.

Upvotes: 3

Related Questions