sometimes , the $element.parent() return null
So, must deWatch,
deWatch = $scope.$watch(uiIfFn, function uiIfWatchAction(value) {
if (value) {
if($element.parent().length == 0){
deWatch();
}else if (!childScope) {
$transclude(function (clone, newScope) {
childScope = newScope;
clone[clone.length++] = document.createComment(' end uiIf: ' + $attr.uiIf + ' ');
// Note: We only need the first/last node of the cloned nodes.
// However, we need to keep the reference to the jqlite wrapper as it might be changed later
// by a directive with templateUrl when its template arrives.
block = {
clone: clone
};
$animate.enter(clone, $element.parent(), $element);
});
}
} else {
if (previousElements) {
...............
sometimes , the $element.parent() return null So, must deWatch,