mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-15 18:23:09 +00:00
docs(provider): replaced coffeescript with comparable javascript example
This commit is contained in:
parent
e1cfb1957f
commit
e324c14907
1 changed files with 16 additions and 11 deletions
|
|
@ -474,7 +474,7 @@ function annotate(fn) {
|
||||||
* constructor function that will be used to instantiate the service instance.
|
* constructor function that will be used to instantiate the service instance.
|
||||||
*
|
*
|
||||||
* You should use {@link AUTO.$provide#methods_service $provide.service(class)} if you define your service
|
* You should use {@link AUTO.$provide#methods_service $provide.service(class)} if you define your service
|
||||||
* as a type/class. This is common when using {@link http://coffeescript.org CoffeeScript}.
|
* as a type/class.
|
||||||
*
|
*
|
||||||
* @param {string} name The name of the instance.
|
* @param {string} name The name of the instance.
|
||||||
* @param {Function} constructor A class (constructor function) that will be instantiated.
|
* @param {Function} constructor A class (constructor function) that will be instantiated.
|
||||||
|
|
@ -482,20 +482,25 @@ function annotate(fn) {
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* 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)} that is defined as a CoffeeScript class.
|
* {@link AUTO.$provide#methods_service $provide.service(class)}.
|
||||||
* <pre>
|
* <pre>
|
||||||
* class Ping
|
* $provide.service('ping', ['$http', function($http) {
|
||||||
* constructor: (@$http) ->
|
* var Ping = function() {
|
||||||
* send: () =>
|
* this.$http = $http;
|
||||||
* @$http.get('/ping')
|
* };
|
||||||
*
|
*
|
||||||
* $provide.service('ping', ['$http', Ping])
|
* Ping.prototype.send = function() {
|
||||||
|
* return this.$http.get('/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>
|
||||||
* someModule.controller 'Ctrl', ['ping', (ping) ->
|
* someModule.controller('Ctrl', ['ping', function(ping) {
|
||||||
* ping.send()
|
* ping.send();
|
||||||
* ]
|
* }]);
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue