mcasimir / mobile-angular-ui

Angular.js Mobile UI Framework with Bootstrap 3
http://mobileangularui.com/
MIT License
2.87k stars 709 forks source link

maybe there's not $element.parent(), in uiIfDirective #316

Open heran opened 8 years ago

heran commented 8 years ago

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) {
                                        ...............
mcasimir commented 8 years ago

Nice catch, thanks. Going to schedule this for work. It would be great to have a PR.