This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ngAnimateChildren): make it compatible with ngIf
Previously, ngAnimateChildren would set the data on the element in an $observe listener, which means the data was available after one digest happend. This is too late when the element is animated immediately after compilation, as happens with ngIf. Now the data is also set right in the linking function. Fixes #13865 Closes #13876
- Loading branch information
Showing
2 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
'use strict'; | ||
|
||
var $$AnimateChildrenDirective = [function() { | ||
return function(scope, element, attrs) { | ||
var val = attrs.ngAnimateChildren; | ||
if (angular.isString(val) && val.length === 0) { //empty attribute | ||
element.data(NG_ANIMATE_CHILDREN_DATA, true); | ||
} else { | ||
attrs.$observe('ngAnimateChildren', function(value) { | ||
var $$AnimateChildrenDirective = ['$interpolate', function($interpolate) { | ||
return { | ||
link: function(scope, element, attrs) { | ||
var val = attrs.ngAnimateChildren; | ||
if (angular.isString(val) && val.length === 0) { //empty attribute | ||
element.data(NG_ANIMATE_CHILDREN_DATA, true); | ||
} else { | ||
// Interpolate and set the value, so that it is available to | ||
// animations that run right after compilation | ||
setData($interpolate(attrs.ngAnimateChildren)(scope)); | ||
attrs.$observe('ngAnimateChildren', setData); | ||
} | ||
|
||
function setData(value) { | ||
value = value === 'on' || value === 'true'; | ||
element.data(NG_ANIMATE_CHILDREN_DATA, value); | ||
}); | ||
} | ||
} | ||
}; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters