diff options
| author | Ken Sheedlo | 2013-08-01 15:11:10 -0700 | 
|---|---|---|
| committer | Igor Minar | 2013-08-07 21:36:59 -0700 | 
| commit | e4b6a1eaa4a432b0082c7abbff8f4bb169cf846e (patch) | |
| tree | c7db8a10cfa64808ac3d750d7d434cbf05c5ea64 /docs/content/error/injector | |
| parent | 306a613440175c7fd61d1d6eb249d1e53a46322e (diff) | |
| download | angular.js-e4b6a1eaa4a432b0082c7abbff8f4bb169cf846e.tar.bz2 | |
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 #3430
Diffstat (limited to 'docs/content/error/injector')
| -rw-r--r-- | docs/content/error/injector/cdep.ngdoc | 22 | ||||
| -rw-r--r-- | docs/content/error/injector/itkn.ngdoc | 22 | ||||
| -rw-r--r-- | docs/content/error/injector/modulerr.ngdoc | 3 | ||||
| -rw-r--r-- | docs/content/error/injector/nomod.ngdoc | 22 | ||||
| -rw-r--r-- | docs/content/error/injector/pget.ngdoc | 22 | ||||
| -rw-r--r-- | docs/content/error/injector/unpr.ngdoc | 22 | 
6 files changed, 113 insertions, 0 deletions
diff --git a/docs/content/error/injector/cdep.ngdoc b/docs/content/error/injector/cdep.ngdoc index f4a9c909..0e9769c4 100644 --- a/docs/content/error/injector/cdep.ngdoc +++ b/docs/content/error/injector/cdep.ngdoc @@ -2,3 +2,25 @@  @name $injector:cdep  @fullName Circular Dependency  @description + +This error occurs when the {@link api/angular.injector $injector} tries to get +a service that depends on itself, either directly or indirectly. To fix this, +construct your dependency chain such that there are no circular dependencies. + +For example: + +``` +angular.module('myApp', []) +  .factory('myService', function (myService) { +    // ... +  }) +  .controller('MyCtrl', function ($scope, myService) { +    // ... +  }); +``` + +When an instance of `MyCtrl` is created, the service `myService` will be created +by the `$injector`. `myService` depends on itself, which causes the `$injector` +to detect a circular dependency and throw the error. + +For more information, see the {@link guide/di Dependency Injection Guide}.
\ No newline at end of file diff --git a/docs/content/error/injector/itkn.ngdoc b/docs/content/error/injector/itkn.ngdoc index fab64696..5437dce7 100644 --- a/docs/content/error/injector/itkn.ngdoc +++ b/docs/content/error/injector/itkn.ngdoc @@ -2,3 +2,25 @@  @name $injector:itkn  @fullName Bad Injection Token  @description + +This error occurs when using a bad token as a dependency injection annotation. +Dependency injection annotation tokens should always be strings. Using any other +type will cause this error to be thrown. + +Examples of code with bad injection tokens include: + +``` +var myCtrl = function ($scope, $http) { /* ... */ }; +myCtrl.$inject = ['$scope', 42]; + +myAppModule.controller('MyCtrl', ['$scope', {}, function ($scope, $timeout) { +  // ... +}]); +``` + +The bad injection tokens are `42` in the first example and `{}` in the second. +To avoid the error, always use string literals for dependency injection annotation +tokens. + +For an explanation of what injection annotations are and how to use them, refer +to the {@link guide/di Dependency Injection Guide}.
\ No newline at end of file diff --git a/docs/content/error/injector/modulerr.ngdoc b/docs/content/error/injector/modulerr.ngdoc index 5d2aa8f8..e9d77c18 100644 --- a/docs/content/error/injector/modulerr.ngdoc +++ b/docs/content/error/injector/modulerr.ngdoc @@ -2,3 +2,6 @@  @name $injector:modulerr  @fullName Module Error  @description + +This error occurs when a module fails to load due to some exception. The error +message above should provide additional context. diff --git a/docs/content/error/injector/nomod.ngdoc b/docs/content/error/injector/nomod.ngdoc index 6dd4c169..66e2a5ad 100644 --- a/docs/content/error/injector/nomod.ngdoc +++ b/docs/content/error/injector/nomod.ngdoc @@ -2,3 +2,25 @@  @name $injector:nomod  @fullName Module Unavailable  @description + +This error occurs when trying to "re-open" a module that has not yet been defined. + +To define a new module, call {@link api/angular.module angular.module} with a name +and an array of dependent modules, like so: + +``` +// When defining a module with no module dependencies, +// the requires array should be defined and empty. +var myApp = angular.module('myApp', []); +``` + +To retrieve a reference to the same module for further configuration, call +`angular.module` without the `requires` array. + +``` +var myApp = angular.module('myApp'); +``` + +Calling `angular.module` without the `requires` array when the module has not yet +been defined causes this error to be thrown. To fix it, define your module with +a name and an empty array, as in the first example above.
\ No newline at end of file diff --git a/docs/content/error/injector/pget.ngdoc b/docs/content/error/injector/pget.ngdoc index 3eca8d80..e296b8ae 100644 --- a/docs/content/error/injector/pget.ngdoc +++ b/docs/content/error/injector/pget.ngdoc @@ -2,3 +2,25 @@  @name $injector:pget  @fullName Provider Missing $get  @description + +This error occurs when attempting to register a provider that does not have a +`$get` method. For example: + +``` +function BadProvider() {} // No $get method! +angular.module("myApp", []) +  .provider('bad', BadProvider);  // this throws the error +``` + +To fix the error, fill in the `$get` method on the provider like so: + +``` +function GoodProvider() { +  this.$get = angular.noop; +} +angular.module("myApp", []) +  .provider('good', GoodProvider); +``` + +For more information, refer to the {@link api/AUTO.$provide#provider +$provide.provider} api doc.
\ No newline at end of file diff --git a/docs/content/error/injector/unpr.ngdoc b/docs/content/error/injector/unpr.ngdoc index 5459711f..1b0faa8e 100644 --- a/docs/content/error/injector/unpr.ngdoc +++ b/docs/content/error/injector/unpr.ngdoc @@ -2,3 +2,25 @@  @name $injector:unpr  @fullName Unknown Provider  @description + +This error results from the `$injector` being unable to resolve a required +dependency. To fix this, make sure the dependency is defined and spelled +correctly. For example: + +``` +angular.module('myApp', []) +  .controller('myCtrl', ['myService', function (myService) { +    // Do something with myService +  }]); +``` + +This code will fail with `$injector:unpr` if `myService` is not defined. Making +sure each dependency is defined will fix the problem. + +``` +angular.module('myApp', []) +  .service('myService', function () { /* ... */ }) +  .controller('myCtrl', ['myService', function (myService) { +    // Do something with myService +  }]); +```
\ No newline at end of file  | 
