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
* There are also shorthand methods to define services that don't need to be configured beyond their `$get()` method.
298
+
*
299
+
* `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.
300
+
*
301
+
* <pre>
302
+
* function TrackingProvider($http) {
303
+
* var observed = {};
304
+
* this.event = function(event) {
305
+
* var current = observed[event];
306
+
* return observed[event] = current ? current + 1 : 1;
307
+
* };
308
+
* this.save = function() {
309
+
* $http.post("/track",observed);
310
+
* };
311
+
* }
312
+
* $provider.service('tracking',TrackingProvider);
313
+
* </pre>
314
+
*
315
+
* `factory()` registers a function whose return value is the instance. Again, you can specify services that will be provided by the injector.
316
+
*
317
+
* <pre>
318
+
* function TrackingProvider($http) {
319
+
* var observed = {};
320
+
* return {
321
+
* event: function(event) {
322
+
* var current = observed[event];
323
+
* return observed[event] = current ? current + 1 : 1;
324
+
* },
325
+
* save: function() {
326
+
* $http.post("/track",observed);
327
+
* }
328
+
* };
329
+
* }
330
+
* $provider.factory('tracking',TrackingProvider);
331
+
* </pre>
332
+
*
296
333
*/
297
334
298
335
/**
@@ -320,7 +357,7 @@ function annotate(fn) {
320
357
* @methodOf AUTO.$provide
321
358
* @description
322
359
*
323
-
* A short hand for configuring services if only `$get` method is required.
360
+
* A service whose instance is the return value of `$getFn`. Short hand for configuring services if only `$get` method is required.
324
361
*
325
362
* @param {string} name The name of the instance.
326
363
* @param {function()} $getFn The $getFn for the instance creation. Internally this is a short hand for
@@ -335,7 +372,7 @@ function annotate(fn) {
335
372
* @methodOf AUTO.$provide
336
373
* @description
337
374
*
338
-
* A short hand for registering service of given class.
375
+
* A service whose instance is created by invoking `constructor` with `new`. A short hand for registering services which use a constructor.
339
376
*
340
377
* @param {string} name The name of the instance.
341
378
* @param {Function} constructor A class (constructor function) that will be instantiated.
@@ -602,3 +639,4 @@ function createInjector(modulesToLoad) {
0 commit comments