diff --git a/.pullapprove.yml b/.pullapprove.yml index ead89ac1cc..fd3b23eea0 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -643,7 +643,8 @@ groups: conditions: - > contains_any_globs(files, [ - 'packages/zone.js/**' + 'packages/zone.js/**', + 'aio/content/guide/zone.md' ]) reviewers: users: diff --git a/aio/content/guide/zone.md b/aio/content/guide/zone.md new file mode 100644 index 0000000000..13c8c2fbb9 --- /dev/null +++ b/aio/content/guide/zone.md @@ -0,0 +1,418 @@ +# NgZone + +A zone is an execution context that persists across async tasks. You can think of it as [thread-local storage](http://en.wikipedia.org/wiki/Thread-local_storage) for JavaScript VMs. +This guide describes how to use Angular's NgZone to automatically detect changes in the component to update HTML. + +## Fundamentals of change detection + +To understand the benefits of `NgZone`, it is important to have a clear grasp of what change detection is and how it works. + +### Displaying and updating data in Angular + +In Angular, you can [display data](guide/displaying-data) by binding controls in an HTML template to the properties of an Angular component. + + + +In addition, you can bind DOM events to a method of an Angular component. In such methods, you can also update a property of the Angular component, which updates the corresponding data displayed in the template. + + + +In both of the above examples, the component's code updates only the property of the component. +However, the HTML is also updated automatically. +This guide describes how and when Angular renders the HTML based on the data from the Angular component. + + +### Detecting changes with plain JavaScript + +To clarify how changes are detected and values updated, consider the following code written in plain JavaScript. + +```javascript + +
+