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

Commit 6c2f667

Browse files
zbjornsonpetebacondarwin
authored andcommitted
feat($compile): backport $doCheck
Backuport ngDoCheck from Angular 2.
1 parent f39e519 commit 6c2f667

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ng/compile.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,12 @@
300300
* `changesObj` is a hash whose keys are the names of the bound properties that have changed, and the values are an
301301
* object of the form `{ currentValue, previousValue, isFirstChange() }`. Use this hook to trigger updates within a
302302
* component such as cloning the bound value to prevent accidental mutation of the outer value.
303-
* * `$doCheck()` - Called on each digest cycle. Provides an opportunity to detect and act on
303+
* * `$doCheck()` - Called on each turn of the digest cycle. Provides an opportunity to detect and act on
304304
* changes. Any actions that you wish to take in response to the changes that you detect must be
305-
* invoked from this hook; implementing this has no effect on when `$onChanges` is called.
305+
* invoked from this hook; implementing this has no effect on when `$onChanges` is called. For example, this hook
306+
* could be useful if you wish to perform a deep equality check, or to check a Date object, changes to which would not
307+
* be detected by Angular's change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments;
308+
* if detecting changes, you must store the previous value(s) for comparison to the current values.
306309
* * `$onDestroy()` - Called on a controller when its containing scope is destroyed. Use this hook for releasing
307310
* external resources, watches and event handlers. Note that components have their `$onDestroy()` hooks called in
308311
* the same order as the `$scope.$broadcast` events are triggered, which is top down. This means that parent
@@ -2505,6 +2508,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
25052508
if (isFunction(controllerInstance.$doCheck)) {
25062509
controllerInstance.$doCheck();
25072510
}
2511+
if (isFunction(controllerInstance.$doCheck)) {
2512+
controllerInstance.$doCheck();
2513+
}
25082514
if (isFunction(controllerInstance.$onDestroy)) {
25092515
controllerScope.$on('$destroy', function callOnDestroyHook() {
25102516
controllerInstance.$onDestroy();

0 commit comments

Comments
 (0)