@@ -187,8 +187,8 @@ To examine the scope in the debugger:
187
187
## Scope Events Propagation
188
188
189
189
Scopes can propagate events in similar fashion to DOM events. The event can be {@link
190
- api/ ng.$rootScope.Scope#methods_$broadcast broadcasted} to the scope children or {@link
191
- api/ ng.$rootScope.Scope#methods_$emit emitted} to scope parents.
190
+ ng.$rootScope.Scope#methods_$broadcast broadcasted} to the scope children or {@link
191
+ ng.$rootScope.Scope#methods_$emit emitted} to scope parents.
192
192
193
193
<example>
194
194
<file name="script.js">
@@ -230,14 +230,14 @@ more events.
230
230
When the browser calls into JavaScript the code executes outside the Angular execution context,
231
231
which means that Angular is unaware of model modifications. To properly process model
232
232
modifications the execution has to enter the Angular execution context using the {@link
233
- api/ ng.$rootScope.Scope#methods_$apply `$apply`} method. Only model modifications which
233
+ ng.$rootScope.Scope#methods_$apply `$apply`} method. Only model modifications which
234
234
execute inside the `$apply` method will be properly accounted for by Angular. For example if a
235
235
directive listens on DOM events, such as {@link
236
- api/ ng.directive:ngClick `ng-click`} it must evaluate the
236
+ ng.directive:ngClick `ng-click`} it must evaluate the
237
237
expression inside the `$apply` method.
238
238
239
239
After evaluating the expression, the `$apply` method performs a {@link
240
- api/ ng.$rootScope.Scope#methods_$digest `$digest`}. In the $digest phase the scope examines all
240
+ ng.$rootScope.Scope#methods_$digest `$digest`}. In the $digest phase the scope examines all
241
241
of the `$watch` expressions and compares them with the previous value. This dirty checking is done
242
242
asynchronously. This means that assignment such as `$scope.username="angular"` will not
243
243
immediately cause a `$watch` to be notified, instead the `$watch` notification is delayed until
@@ -255,13 +255,13 @@ the `$digest` phase. This delay is desirable, since it coalesces multiple model
255
255
2. **Watcher registration**
256
256
257
257
During template linking directives register {@link
258
- api/ ng.$rootScope.Scope#methods_$watch watches} on the scope. These watches will be
258
+ ng.$rootScope.Scope#methods_$watch watches} on the scope. These watches will be
259
259
used to propagate model values to the DOM.
260
260
261
261
3. **Model mutation**
262
262
263
263
For mutations to be properly observed, you should make them only within the {@link
264
- api/ ng.$rootScope.Scope#methods_$apply scope.$apply()}. (Angular APIs do this
264
+ ng.$rootScope.Scope#methods_$apply scope.$apply()}. (Angular APIs do this
265
265
implicitly, so no extra `$apply` call is needed when doing synchronous work in controllers,
266
266
or asynchronous work with {@link ng.$http $http}, {@link ng.$timeout $timeout}
267
267
or {@link ng.$interval $interval} services.
@@ -284,30 +284,30 @@ the `$digest` phase. This delay is desirable, since it coalesces multiple model
284
284
### Scopes and Directives
285
285
286
286
During the compilation phase, the {@link compiler compiler} matches {@link
287
- api/ ng.$compileProvider#methods_directive directives} against the DOM template. The directives
287
+ ng.$compileProvider#methods_directive directives} against the DOM template. The directives
288
288
usually fall into one of two categories:
289
289
290
290
- Observing {@link ng.$compileProvider#methods_directive directives}, such as
291
291
double-curly expressions `{{expression}}`, register listeners using the {@link
292
- api/ ng.$rootScope.Scope#methods_$watch $watch()} method. This type of directive needs
292
+ ng.$rootScope.Scope#methods_$watch $watch()} method. This type of directive needs
293
293
to be notified whenever the expression changes so that it can update the view.
294
294
295
295
- Listener directives, such as {@link ng.directive:ngClick
296
296
ng-click}, register a listener with the DOM. When the DOM listener fires, the directive
297
297
executes the associated expression and updates the view using the {@link
298
- api/ ng.$rootScope.Scope#methods_$apply $apply()} method.
298
+ ng.$rootScope.Scope#methods_$apply $apply()} method.
299
299
300
300
When an external event (such as a user action, timer or XHR) is received, the associated {@link
301
301
expression expression} must be applied to the scope through the {@link
302
- api/ ng.$rootScope.Scope#methods_$apply $apply()} method so that all listeners are updated
302
+ ng.$rootScope.Scope#methods_$apply $apply()} method so that all listeners are updated
303
303
correctly.
304
304
305
305
### Directives that Create Scopes
306
306
307
307
In most cases, {@link ng.$compileProvider#methods_directive directives} and scopes interact
308
308
but do not create new instances of scope. However, some directives, such as {@link
309
- api/ ng.directive:ngController ng-controller} and {@link
310
- api/ ng.directive:ngRepeat ng-repeat}, create new child scopes
309
+ ng.directive:ngController ng-controller} and {@link
310
+ ng.directive:ngRepeat ng-repeat}, create new child scopes
311
311
and attach the child scope to the corresponding DOM element. You can retrieve a scope for any DOM
312
312
element by using an `angular.element(aDomElement).scope()` method call.
313
313
See the {@link guide/directive#creating-custom-directives_demo_isolating-the-scope-of-a-directive
@@ -318,7 +318,7 @@ directives guide} for more information about isolate scopes.
318
318
Scopes and controllers interact with each other in the following situations:
319
319
320
320
- Controllers use scopes to expose controller methods to templates (see {@link
321
- api/ ng.directive:ngController ng-controller}).
321
+ ng.directive:ngController ng-controller}).
322
322
323
323
- Controllers define methods (behavior) that can mutate the model (properties on the scope).
324
324
@@ -357,14 +357,14 @@ directive which is handling the event. An explicit call to $apply is needed only
357
357
implementing custom event callbacks, or when working with third-party library callbacks.
358
358
359
359
1. Enter Angular execution context by calling {@link guide/scope scope}`.`{@link
360
- api/ ng.$rootScope.Scope#methods_$apply $apply}`(stimulusFn)`. Where `stimulusFn` is
360
+ ng.$rootScope.Scope#methods_$apply $apply}`(stimulusFn)`. Where `stimulusFn` is
361
361
the work you wish to do in Angular execution context.
362
362
2. Angular executes the `stimulusFn()`, which typically modifies application state.
363
363
3. Angular enters the {@link ng.$rootScope.Scope#methods_$digest $digest} loop. The
364
364
loop is made up of two smaller loops which process {@link
365
- api/ ng.$rootScope.Scope#methods_$evalAsync $evalAsync} queue and the {@link
366
- api/ ng.$rootScope.Scope#methods_$watch $watch} list. The {@link
367
- api/ ng.$rootScope.Scope#methods_$digest $digest} loop keeps iterating until the model
365
+ ng.$rootScope.Scope#methods_$evalAsync $evalAsync} queue and the {@link
366
+ ng.$rootScope.Scope#methods_$watch $watch} list. The {@link
367
+ ng.$rootScope.Scope#methods_$digest $digest} loop keeps iterating until the model
368
368
stabilizes, which means that the {@link ng.$rootScope.Scope#methods_$evalAsync
369
369
$evalAsync} queue is empty and the {@link ng.$rootScope.Scope#methods_$watch
370
370
$watch} list does not detect any changes.
@@ -386,7 +386,7 @@ user enters text into the text field.
386
386
387
387
1. During the compilation phase:
388
388
1. the {@link ng.directive:ngModel ng-model} and {@link
389
- api/ ng.directive:input input} {@link guide/directive
389
+ ng.directive:input input} {@link guide/directive
390
390
directive} set up a `keydown` listener on the `<input>` control.
391
391
2. the {@link ng.$interpolate {{name}} } interpolation
392
392
sets up a {@link ng.$rootScope.Scope#methods_$watch $watch} to be notified of
@@ -395,7 +395,7 @@ user enters text into the text field.
395
395
1. Pressing an '`X`' key causes the browser to emit a `keydown` event on the input control.
396
396
2. The {@link ng.directive:input input} directive
397
397
captures the change to the input's value and calls {@link
398
- api/ ng.$rootScope.Scope#methods_$apply $apply}`("name = 'X';")` to update the
398
+ ng.$rootScope.Scope#methods_$apply $apply}`("name = 'X';")` to update the
399
399
application model inside the Angular execution context.
400
400
3. Angular applies the `name = 'X';` to the model.
401
401
4. The {@link ng.$rootScope.Scope#methods_$digest $digest} loop begins
0 commit comments