You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
* There are also shorthand methods to define services that don't need to be configured beyond their `$get()` method.
314
+
*
315
+
* `service()` registers a constructor function which will be invoked with `new` to create the instance. You can specify services that will be provided by the injector.
316
+
*
317
+
* <pre>
318
+
* function TrackingProvider($http) {
319
+
* var observed = {};
320
+
* this.event = function(event) {
321
+
* var current = observed[event];
322
+
* return observed[event] = current ? current + 1 : 1;
323
+
* };
324
+
* this.save = function() {
325
+
* $http.post("/track",observed);
326
+
* };
327
+
* }
328
+
* $provider.service('tracking',TrackingProvider);
329
+
* </pre>
330
+
*
331
+
* `factory()` registers a function whose return value is the instance. Again, you can specify services that will be provided by the injector.
332
+
*
333
+
* <pre>
334
+
* function TrackingProvider($http) {
335
+
* var observed = {};
336
+
* return {
337
+
* event: function(event) {
338
+
* var current = observed[event];
339
+
* return observed[event] = current ? current + 1 : 1;
340
+
* },
341
+
* save: function() {
342
+
* $http.post("/track",observed);
343
+
* }
344
+
* };
345
+
* }
346
+
* $provider.factory('tracking',TrackingProvider);
347
+
* </pre>
348
+
*
312
349
*/
313
350
314
351
/**
@@ -336,7 +373,7 @@ function annotate(fn) {
336
373
* @methodOf AUTO.$provide
337
374
* @description
338
375
*
339
-
* A short hand for configuring services if only `$get` method is required.
376
+
* A service whose instance is the return value of `$getFn`. Short hand for configuring services if only `$get` method is required.
340
377
*
341
378
* @param {string} name The name of the instance.
342
379
* @param {function()} $getFn The $getFn for the instance creation. Internally this is a short hand for
@@ -351,7 +388,7 @@ function annotate(fn) {
351
388
* @methodOf AUTO.$provide
352
389
* @description
353
390
*
354
-
* A short hand for registering service of given class.
391
+
* A service whose instance is created by invoking `constructor` with `new`. A short hand for registering services which use a constructor.
355
392
*
356
393
* @param {string} name The name of the instance.
357
394
* @param {Function} constructor A class (constructor function) that will be instantiated.
@@ -621,3 +658,4 @@ function createInjector(modulesToLoad) {
0 commit comments