mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-27 18:04:47 +00:00
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
This commit is contained in:
parent
7a78aed160
commit
e2173f9101
1 changed files with 9 additions and 10 deletions
|
|
@ -482,17 +482,16 @@ function annotate(fn) {
|
||||||
* Here is an example of registering a service using
|
* Here is an example of registering a service using
|
||||||
* {@link AUTO.$provide#methods_service $provide.service(class)}.
|
* {@link AUTO.$provide#methods_service $provide.service(class)}.
|
||||||
* <pre>
|
* <pre>
|
||||||
* $provide.service('ping', ['$http', function($http) {
|
* var Ping = function($http) {
|
||||||
* var Ping = function() {
|
* this.$http = $http;
|
||||||
* this.$http = $http;
|
* };
|
||||||
* };
|
*
|
||||||
|
* Ping.$inject = ['$http'];
|
||||||
*
|
*
|
||||||
* Ping.prototype.send = function() {
|
* Ping.prototype.send = function() {
|
||||||
* return this.$http.get('/ping');
|
* return this.$http.get('/ping');
|
||||||
* };
|
* };
|
||||||
*
|
* $provide.service('ping', Ping);
|
||||||
* return Ping;
|
|
||||||
* }]);
|
|
||||||
* </pre>
|
* </pre>
|
||||||
* You would then inject and use this service like this:
|
* You would then inject and use this service like this:
|
||||||
* <pre>
|
* <pre>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue