|
300 | 300 | * `changesObj` is a hash whose keys are the names of the bound properties that have changed, and the values are an
|
301 | 301 | * object of the form `{ currentValue, previousValue, isFirstChange() }`. Use this hook to trigger updates within a
|
302 | 302 | * 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 |
| 304 | + * 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. |
303 | 306 | * * `$onDestroy()` - Called on a controller when its containing scope is destroyed. Use this hook for releasing
|
304 | 307 | * external resources, watches and event handlers. Note that components have their `$onDestroy()` hooks called in
|
305 | 308 | * the same order as the `$scope.$broadcast` events are triggered, which is top down. This means that parent
|
@@ -2499,6 +2502,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
2499 | 2502 | $exceptionHandler(e);
|
2500 | 2503 | }
|
2501 | 2504 | }
|
| 2505 | + if (isFunction(controllerInstance.$doCheck)) { |
| 2506 | + controllerInstance.$doCheck(); |
| 2507 | + } |
2502 | 2508 | if (isFunction(controllerInstance.$onDestroy)) {
|
2503 | 2509 | controllerScope.$on('$destroy', function callOnDestroyHook() {
|
2504 | 2510 | controllerInstance.$onDestroy();
|
@@ -3151,7 +3157,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
3151 | 3157 | forEach(bindings, function initializeBinding(definition, scopeName) {
|
3152 | 3158 | var attrName = definition.attrName,
|
3153 | 3159 | optional = definition.optional,
|
3154 |
| - mode = definition.mode, // @, =, or & |
| 3160 | + mode = definition.mode, // @, =, <, or & |
3155 | 3161 | lastValue,
|
3156 | 3162 | parentGet, parentSet, compare, removeWatch;
|
3157 | 3163 |
|
@@ -3263,6 +3269,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
3263 | 3269 | }
|
3264 | 3270 | });
|
3265 | 3271 |
|
| 3272 | + if (isFunction(destination.$doCheck)) { |
| 3273 | + var doCheckWatch = scope.$watch(triggerDoCheckHook); |
| 3274 | + removeWatchCollection.push(doCheckWatch); |
| 3275 | + } |
| 3276 | + |
3266 | 3277 | function recordChanges(key, currentValue, previousValue) {
|
3267 | 3278 | if (isFunction(destination.$onChanges) && currentValue !== previousValue) {
|
3268 | 3279 | // If we have not already scheduled the top level onChangesQueue handler then do so now
|
@@ -3290,6 +3301,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
3290 | 3301 | changes = undefined;
|
3291 | 3302 | }
|
3292 | 3303 |
|
| 3304 | + function triggerDoCheckHook() { |
| 3305 | + destination.$doCheck(); |
| 3306 | + } |
| 3307 | + |
3293 | 3308 | return {
|
3294 | 3309 | initialChanges: initialChanges,
|
3295 | 3310 | removeWatches: removeWatchCollection.length && function removeWatches() {
|
|
0 commit comments