diff options
| author | Caitlin Potter | 2014-02-06 14:02:18 +0000 |
|---|---|---|
| committer | Peter Bacon Darwin | 2014-02-16 19:03:40 +0000 |
| commit | f7d28cd377f06224247b950680517a187a7b6749 (patch) | |
| tree | 20203b9f7bf60748bb752f325b1869415352a6f3 /docs/content/guide/dev_guide.services.creating_services.ngdoc | |
| parent | 2e641ac49f121a6e2cc70bd3879930b44a8a7710 (diff) | |
| download | angular.js-f7d28cd377f06224247b950680517a187a7b6749.tar.bz2 | |
docs(all): convert <pre>/</pre> snippets to GFM snippets
Diffstat (limited to 'docs/content/guide/dev_guide.services.creating_services.ngdoc')
| -rw-r--r-- | docs/content/guide/dev_guide.services.creating_services.ngdoc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/docs/content/guide/dev_guide.services.creating_services.ngdoc b/docs/content/guide/dev_guide.services.creating_services.ngdoc index bdcf42ad..c6210cc1 100644 --- a/docs/content/guide/dev_guide.services.creating_services.ngdoc +++ b/docs/content/guide/dev_guide.services.creating_services.ngdoc @@ -22,17 +22,19 @@ by using the {@link api/AUTO.$provide $provide} service in the module configurat function. The following pseudo-code shows both approaches: Using the angular.Module api: -<pre> + +```js var myModule = angular.module('myModule', []); myModule.factory('serviceId', function() { var shinyNewServiceInstance; //factory function body that constructs shinyNewServiceInstance return shinyNewServiceInstance; }); -</pre> +``` Using the $provide service: -<pre> + +```js angular.module('myModule', [], function($provide) { $provide.factory('serviceId', function() { var shinyNewServiceInstance; @@ -40,7 +42,7 @@ angular.module('myModule', [], function($provide) { return shinyNewServiceInstance; }); }); -</pre> +``` Note that you are not registering a service instance, but rather a factory function that will create this instance when called. @@ -58,7 +60,7 @@ Following is an example of a very simple service. This service depends on the `$ stores all notifications; after the third one, the service displays all of the notifications by window alert. -<pre> +```js angular.module('myModule', [], function($provide) { $provide.factory('notify', ['$window', function(win) { var msgs = []; @@ -71,7 +73,7 @@ angular.module('myModule', [], function($provide) { }; }]); }); -</pre> +``` # Instantiating Angular Services |
