diff options
| author | Clark Pan | 2014-01-28 11:53:25 +1100 |
|---|---|---|
| committer | Caitlin Potter | 2014-01-29 09:10:01 -0500 |
| commit | e2173f9101545b60367fd95524232fb8cf2eabca (patch) | |
| tree | 10a6732d6bbfe763a04735f2ba91da033ab1a5fd /src/auto/injector.js | |
| parent | 7a78aed1603ca7f60f2f70ba27f0102e08862550 (diff) | |
| download | angular.js-e2173f9101545b60367fd95524232fb8cf2eabca.tar.bz2 | |
docs($provide): return instance of Ping, rather than constructor
Updating $provide.service method docs
The previous example provided for the service method did not work. I've updated the example to a working example.
I think this version of the example will probably make more sense to most people, and the factory method would be
a better place for this sort of example.
Closes #6008
Diffstat (limited to 'src/auto/injector.js')
| -rw-r--r-- | src/auto/injector.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/auto/injector.js b/src/auto/injector.js index becc878d..3d2ac628 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -482,17 +482,16 @@ function annotate(fn) { * Here is an example of registering a service using * {@link AUTO.$provide#methods_service $provide.service(class)}. * <pre> - * $provide.service('ping', ['$http', function($http) { - * var Ping = function() { - * this.$http = $http; - * }; - * - * Ping.prototype.send = function() { - * return this.$http.get('/ping'); - * }; + * var Ping = function($http) { + * this.$http = $http; + * }; + * + * Ping.$inject = ['$http']; * - * return Ping; - * }]); + * Ping.prototype.send = function() { + * return this.$http.get('/ping'); + * }; + * $provide.service('ping', Ping); * </pre> * You would then inject and use this service like this: * <pre> |
