mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +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
|
||||
* {@link AUTO.$provide#methods_service $provide.service(class)}.
|
||||
* <pre>
|
||||
* $provide.service('ping', ['$http', function($http) {
|
||||
* var Ping = function() {
|
||||
* this.$http = $http;
|
||||
* };
|
||||
* var Ping = function($http) {
|
||||
* this.$http = $http;
|
||||
* };
|
||||
*
|
||||
* Ping.$inject = ['$http'];
|
||||
*
|
||||
* Ping.prototype.send = function() {
|
||||
* return this.$http.get('/ping');
|
||||
* };
|
||||
*
|
||||
* 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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue