Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit eb5fd40

Browse files
committed
docs(concept): correct example for creating injector
1 parent 0472c5f commit eb5fd40

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

docs/content/guide/concepts.ngdoc

+25-25
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ This is how we get the ball rolling (refer to the diagram and example below):
3232
4. Angular looks for {@link api/ng.directive:ngApp ng-app}
3333
{@link guide/directive directive}, which designates application boundary
3434
5. {@link guide/module Module} specified in {@link
35-
api/ng.directive:ngApp ng-app} (if any) is used to configure
35+
api/ng.directive:ngApp ng-app} (if any) is used to configure
3636
the {@link api/AUTO.$injector $injector}
3737
6. {@link api/AUTO.$injector $injector} is used to create the {@link
3838
api/ng.$compile $compile} service as well as {@link
3939
api/ng.$rootScope $rootScope}
40-
7. {@link api/ng.$compile $compile} service is used to compile the DOM and link
40+
7. {@link api/ng.$compile $compile} service is used to compile the DOM and link
4141
it with {@link api/ng.$rootScope $rootScope}
42-
8. {@link api/ng.directive:ngInit ng-init} {@link
42+
8. {@link api/ng.directive:ngInit ng-init} {@link
4343
guide/directive directive} assigns `World` to the `name` property on the {@link guide/scope
4444
scope}
4545
9. The `{{name}}` {@link api/ng.$interpolate interpolates} the expression to
@@ -80,8 +80,8 @@ implementing custom event callbacks, or when working with a third-party library
8080
api/ng.$rootScope.Scope#$apply $apply}`(stimulusFn)`. Where `stimulusFn` is
8181
the work you wish to do in Angular execution context.
8282
2. Angular executes the `stimulusFn()`, which typically modifies application state.
83-
3. Angular enters the {@link api/ng.$rootScope.Scope#$digest $digest} loop. The
84-
loop is made up of two smaller loops which process {@link
83+
3. Angular enters the {@link api/ng.$rootScope.Scope#$digest $digest} loop. The
84+
loop is made up of two smaller loops which process {@link
8585
api/ng.$rootScope.Scope#$evalAsync $evalAsync} queue and the {@link
8686
api/ng.$rootScope.Scope#$watch $watch} list. The {@link
8787
api/ng.$rootScope.Scope#$digest $digest} loop keeps iterating until the model
@@ -96,7 +96,7 @@ implementing custom event callbacks, or when working with a third-party library
9696
5. The {@link api/ng.$rootScope.Scope#$watch $watch} list is a set of expressions
9797
which may have changed since last iteration. If a change is detected then the `$watch`
9898
function is called which typically updates the DOM with the new value.
99-
6. Once Angular {@link api/ng.$rootScope.Scope#$digest $digest} loop finishes
99+
6. Once Angular {@link api/ng.$rootScope.Scope#$digest $digest} loop finishes
100100
the execution leaves the Angular and JavaScript context. This is followed by the browser
101101
re-rendering the DOM to reflect any changes.
102102

@@ -122,7 +122,7 @@ user enters text into the text field.
122122
5. The {@link api/ng.$rootScope.Scope#$watch $watch} list detects a change
123123
on the `name` property and notifies the {@link api/ng.$interpolate
124124
{{name}} } interpolation, which in turn updates the DOM.
125-
6. Angular exits the execution context, which in turn exits the `keydown` event and with it
125+
6. Angular exits the execution context, which in turn exits the `keydown` event and with it
126126
the JavaScript execution context.
127127
7. The browser re-renders the view with update text.
128128

@@ -165,7 +165,7 @@ a diagram depicting the scope boundaries.
165165
function GreetCtrl($scope) {
166166
$scope.name = 'World';
167167
}
168-
168+
169169
function ListCtrl($scope) {
170170
$scope.names = ['Igor', 'Misko', 'Vojta'];
171171
}
@@ -196,7 +196,7 @@ controller.
196196
The separation of the controller and the view is important because:
197197

198198
* The controller is written in JavaScript. JavaScript is imperative. Imperative is a good fit
199-
for specifying application behavior. The controller should not contain any rendering
199+
for specifying application behavior. The controller should not contain any rendering
200200
information (DOM references or HTML fragments).
201201
* The view template is written in HTML. HTML is declarative. Declarative is a good fit for
202202
specifying UI. The View should not contain any behavior.
@@ -220,7 +220,7 @@ The separation of the controller and the view is important because:
220220
$scope.action = function() {
221221
$scope.name = 'OK';
222222
}
223-
223+
224224
$scope.name = 'World';
225225
}
226226
</file>
@@ -249,8 +249,8 @@ primitive, object hash, or a full object Type. In short the model is a plain Jav
249249
<img class="pull-right" style="padding-left: 3em; padding-bottom: 1em;" src="img/guide/concepts-view.png">
250250

251251
The view is what the users sees. The view begins its life as a template, it is merged with the
252-
model and finally rendered into the browser DOM. Angular takes a very different approach to
253-
rendering the view, to most other templating systems.
252+
model and finally rendered into the browser DOM. Angular takes a very different approach to
253+
rendering the view, to most other templating systems.
254254

255255
* **Others** - Most templating systems begin as an HTML string with special templating markup.
256256
Often the template markup breaks the HTML syntax which means that the template can not be
@@ -260,13 +260,13 @@ rendering the view, to most other templating systems.
260260
When the model changes the whole process needs to be repeated. The granularity of the template
261261
is the granularity of the DOM updates. The key here is that the templating system manipulates
262262
strings.
263-
* **Angular** - Angular is different, since its templating system works on DOM objects not on
263+
* **Angular** - Angular is different, since its templating system works on DOM objects not on
264264
strings. The template is still written in HTML string, but it is HTML (not HTML with
265265
template sprinkled in.) The browser parses the HTML into DOM, and the DOM becomes the input to
266266
the template engine know as the {@link api/ng.$compile compiler}. The compiler
267267
looks for {@link guide/directive directives} which in turn set up {@link
268268
api/ng.$rootScope.Scope#$watch watches} on the model. The result is a
269-
continuously updating view which does not need template model re-merging. Your model becomes
269+
continuously updating view which does not need template model re-merging. Your model becomes
270270
the single source-of-truth for your view.
271271

272272
<div class="clear">
@@ -345,7 +345,7 @@ They are follow the spirit of UNIX filters and follow similar syntax `|` (pipe).
345345
<file name="index.html">
346346
<div ng-init="list = ['Chrome', 'Safari', 'Firefox', 'IE'] ">
347347
Number formatting: {{ 1234567890 | number }} <br>
348-
array filtering <input ng-model="predicate">
348+
array filtering <input ng-model="predicate">
349349
{{ list | filter:predicate | json }}
350350
</div>
351351
</file>
@@ -373,20 +373,20 @@ as a {@link api/AUTO.$provide provider}.
373373
<pre>
374374
// Create a module
375375
var myModule = angular.module('myModule', [])
376-
376+
377377
// Configure the injector
378378
myModule.factory('serviceA', function() {
379379
return {
380380
// instead of {}, put your object creation here
381381
};
382382
});
383-
383+
384384
// create an injector and configure it from 'myModule'
385-
var $injector = angular.injector('myModule');
386-
385+
var $injector = angular.injector(['myModule']);
386+
387387
// retrieve an object from the injector by name
388388
var serviceA = $injector.get('serviceA');
389-
389+
390390
// always true because of instance cache
391391
$injector.get('serviceA') === $injector.get('serviceA');
392392
</pre>
@@ -405,12 +405,12 @@ allows the methods and types to ask for their dependencies rather then to look f
405405

406406
// Angular provides the injector for your application
407407
var $injector = ...;
408-
408+
409409
///////////////////////////////////////////////
410410
// the old-school way of getting dependencies.
411411
var serviceA = $injector.get('serviceA');
412412
var serviceB = $injector.get('serviceB');
413-
413+
414414
// now call the function
415415
doSomething(serviceA, serviceB);
416416

@@ -442,15 +442,15 @@ dependencies, look for dependencies, or even get a reference to the injector.
442442
// which will be available for injection
443443
factory('time', function($timeout) {
444444
var time = {};
445-
445+
446446
(function tick() {
447447
time.now = new Date().toString();
448448
$timeout(tick, 1000);
449449
})();
450450
return time;
451451
});
452-
453-
// Notice that you can simply ask for time
452+
453+
// Notice that you can simply ask for time
454454
// and it will be provided. No need to look for it.
455455
function ClockCtrl($scope, time) {
456456
$scope.time = time;

0 commit comments

Comments
 (0)