Skip to content

Commit e4b6a1e

Browse files
ksheedloIgorMinar
authored andcommitted
docs(minerr): fill in error message descriptions
Errors I've documented so far: - `$injector:cdep` - `$injector:itkn` - `$injector:modulerr` - `$injector:nomod` - `$injector:pget` - `$injector:unpr` - `ng:areq` - `ng:cpi` - `ng:cpws` - `ngModel:noass` Closes angular#3430
1 parent 306a613 commit e4b6a1e

18 files changed

Lines changed: 181 additions & 6 deletions

File tree

docs/content/error/httpBackend/noxhr.ngdoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
@name $httpBackend:noxhr
33
@fullName Unsupported XHR
44
@description
5+
6+
This error occurs in browsers that do not support XmlHttpRequest. AngularJS
7+
supports Safari, Chrome, Firefox, Opera, IE8 and higher, and mobile browsers
8+
(Android, Chrome Mobile, iOS Safari). To avoid this error, use an officially
9+
supported browser.

docs/content/error/injector/cdep.ngdoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
@name $injector:cdep
33
@fullName Circular Dependency
44
@description
5+
6+
This error occurs when the {@link api/angular.injector $injector} tries to get
7+
a service that depends on itself, either directly or indirectly. To fix this,
8+
construct your dependency chain such that there are no circular dependencies.
9+
10+
For example:
11+
12+
```
13+
angular.module('myApp', [])
14+
.factory('myService', function (myService) {
15+
// ...
16+
})
17+
.controller('MyCtrl', function ($scope, myService) {
18+
// ...
19+
});
20+
```
21+
22+
When an instance of `MyCtrl` is created, the service `myService` will be created
23+
by the `$injector`. `myService` depends on itself, which causes the `$injector`
24+
to detect a circular dependency and throw the error.
25+
26+
For more information, see the {@link guide/di Dependency Injection Guide}.

docs/content/error/injector/itkn.ngdoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
@name $injector:itkn
33
@fullName Bad Injection Token
44
@description
5+
6+
This error occurs when using a bad token as a dependency injection annotation.
7+
Dependency injection annotation tokens should always be strings. Using any other
8+
type will cause this error to be thrown.
9+
10+
Examples of code with bad injection tokens include:
11+
12+
```
13+
var myCtrl = function ($scope, $http) { /* ... */ };
14+
myCtrl.$inject = ['$scope', 42];
15+
16+
myAppModule.controller('MyCtrl', ['$scope', {}, function ($scope, $timeout) {
17+
// ...
18+
}]);
19+
```
20+
21+
The bad injection tokens are `42` in the first example and `{}` in the second.
22+
To avoid the error, always use string literals for dependency injection annotation
23+
tokens.
24+
25+
For an explanation of what injection annotations are and how to use them, refer
26+
to the {@link guide/di Dependency Injection Guide}.

docs/content/error/injector/modulerr.ngdoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
@name $injector:modulerr
33
@fullName Module Error
44
@description
5+
6+
This error occurs when a module fails to load due to some exception. The error
7+
message above should provide additional context.

docs/content/error/injector/nomod.ngdoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
@name $injector:nomod
33
@fullName Module Unavailable
44
@description
5+
6+
This error occurs when trying to "re-open" a module that has not yet been defined.
7+
8+
To define a new module, call {@link api/angular.module angular.module} with a name
9+
and an array of dependent modules, like so:
10+
11+
```
12+
// When defining a module with no module dependencies,
13+
// the requires array should be defined and empty.
14+
var myApp = angular.module('myApp', []);
15+
```
16+
17+
To retrieve a reference to the same module for further configuration, call
18+
`angular.module` without the `requires` array.
19+
20+
```
21+
var myApp = angular.module('myApp');
22+
```
23+
24+
Calling `angular.module` without the `requires` array when the module has not yet
25+
been defined causes this error to be thrown. To fix it, define your module with
26+
a name and an empty array, as in the first example above.

docs/content/error/injector/pget.ngdoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
@name $injector:pget
33
@fullName Provider Missing $get
44
@description
5+
6+
This error occurs when attempting to register a provider that does not have a
7+
`$get` method. For example:
8+
9+
```
10+
function BadProvider() {} // No $get method!
11+
angular.module("myApp", [])
12+
.provider('bad', BadProvider); // this throws the error
13+
```
14+
15+
To fix the error, fill in the `$get` method on the provider like so:
16+
17+
```
18+
function GoodProvider() {
19+
this.$get = angular.noop;
20+
}
21+
angular.module("myApp", [])
22+
.provider('good', GoodProvider);
23+
```
24+
25+
For more information, refer to the {@link api/AUTO.$provide#provider
26+
$provide.provider} api doc.

docs/content/error/injector/unpr.ngdoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
@name $injector:unpr
33
@fullName Unknown Provider
44
@description
5+
6+
This error results from the `$injector` being unable to resolve a required
7+
dependency. To fix this, make sure the dependency is defined and spelled
8+
correctly. For example:
9+
10+
```
11+
angular.module('myApp', [])
12+
.controller('myCtrl', ['myService', function (myService) {
13+
// Do something with myService
14+
}]);
15+
```
16+
17+
This code will fail with `$injector:unpr` if `myService` is not defined. Making
18+
sure each dependency is defined will fix the problem.
19+
20+
```
21+
angular.module('myApp', [])
22+
.service('myService', function () { /* ... */ })
23+
.controller('myCtrl', ['myService', function (myService) {
24+
// Do something with myService
25+
}]);
26+
```

docs/content/error/interpolate/interr.ngdoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
@name $interpolate:interr
33
@fullName Interpolation Error
44
@description
5+
6+
This error occurs when interpolation fails due to some exception. The error
7+
message above should provide additional context.

docs/content/error/interpolate/noconcat.ngdoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@
22
@name $interpolate:noconcat
33
@fullName Multiple Expressions
44
@description
5+
6+
This error occurs when performing an interpolation that concatenates multiple
7+
expressions when a trusted value is required. Concatenating expressions makes
8+
it hard to reason about whether some combination of concatenated values are
9+
unsafe to use and could easily lead to XSS.
10+
11+
For more information about how AngularJS helps keep your app secure, refer to
12+
the {@link api/ng.$sce $sce} API doc.

docs/content/error/jqLite/off_args.ngdoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
@name jqLite:off_args
33
@fullName Invalid jqLite#off() parameter
44
@description
5+
6+
This error occurs when trying to pass too many arguments to `jqLite#off`. Note
7+
that `jqLite#off` does not support namespaces or selectors like jQuery.

0 commit comments

Comments
 (0)