aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/module.ngdoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/guide/module.ngdoc')
-rw-r--r--docs/content/guide/module.ngdoc22
1 files changed, 12 insertions, 10 deletions
diff --git a/docs/content/guide/module.ngdoc b/docs/content/guide/module.ngdoc
index 8bf0eba6..417d3837 100644
--- a/docs/content/guide/module.ngdoc
+++ b/docs/content/guide/module.ngdoc
@@ -126,7 +126,7 @@ of blocks:
application. Only instances and constants can be injected into run blocks. This is to prevent
further system configuration during application run time.
-<pre>
+```js
angular.module('myModule', []).
config(function(injectables) { // provider-injector
// This is an example of config block.
@@ -140,14 +140,14 @@ angular.module('myModule', []).
// You can only inject instances (not Providers)
// into the run blocks
});
-</pre>
+```
## Configuration Blocks
There are some convenience methods on the module which are equivalent to the config block. For
example:
-<pre>
+```js
angular.module('myModule', []).
value('a', 123).
factory('a', function() { return 123; }).
@@ -163,7 +163,7 @@ angular.module('myModule', []).
$compileProvider.directive('directiveName', ...);
$filterProvider.register('filterName', ...);
});
-</pre>
+```
The configuration blocks get applied in the order in which they are registered. The only exception
to it are constant definitions, which are placed at the beginning of all configuration blocks.
@@ -196,7 +196,7 @@ and thus script loaders can take advantage of this property and parallelize the
Beware that using `angular.module('myModule', [])` will create the module `myModule` and overwrite any
existing module named `myModule`. Use `angular.module('myModule')` to retrieve an existing module.
-<pre>
+```js
var myModule = angular.module('myModule', []);
// add some directives and services
@@ -208,7 +208,7 @@ existing module named `myModule`. Use `angular.module('myModule')` to retrieve a
// throws an error because myOtherModule has yet to be defined
var myModule = angular.module('myOtherModule');
-</pre>
+```
# Unit Testing
@@ -219,7 +219,8 @@ injector, which means that the modules are loaded multiple times per VM. Properl
modules can help with unit testing, as in this example:
In all of these examples we are going to assume this module definition:
-<pre>
+
+```js
angular.module('greetMod', []).
factory('alert', function($window) {
@@ -235,10 +236,11 @@ In all of these examples we are going to assume this module definition:
alert(salutation + ' ' + name + '!');
}
});
-</pre>
+```
Let's write some tests:
-<pre>
+
+```js
describe('myApp', function() {
// load the relevant application modules then load a special
// test module which overrides the $window with a mock version,
@@ -272,4 +274,4 @@ describe('myApp', function() {
});
});
});
-</pre>
+```