Skip to content

Commit 78761f1

Browse files
ahmedalejonetman92
authored andcommitted
docs(minerr/unpr): provide more info on $scope injection errors
Closes angular#11030
1 parent 757a70e commit 78761f1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/content/error/$injector/unpr.ngdoc

+12
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ angular.module('myModule', [])
6969
```
7070

7171
Use the `$controller` service if you want to instantiate controllers yourself.
72+
73+
Attempting to inject a scope object into anything that's not a controller or a directive,
74+
for example a service, will also throw an `Unknown provider: $scopeProvider <- $scope` error.
75+
This might happen if one mistakenly registers a controller as a service, ex.:
76+
77+
```
78+
angular.module('myModule', [])
79+
.service('MyController', ['$scope', function($scope) {
80+
// This controller throws an unknown provider error because
81+
// a scope object cannot be injected into a service.
82+
}]);
83+
```

0 commit comments

Comments
 (0)