UI Bootstrap 日期选择器在附加到正文时会重复

Bor*_*eco 5 angularjs angular-ui-bootstrap angular-ui-grid angular-ui-datepicker

ui.bootstrap.datepickerPopup在 内部的过滤器标头模板中使用ui.grid。这让我可以按日期过滤行。我的网格菜单内还有一个用于切换的按钮grid.options.enableFiltering

由于 的对齐问题ui-grid,我有datepicker-append-to-body日期选择器设置为 true。第一次启用过滤时,一切正常。但是,当我禁用过滤并重新启用它时,我会得到重复的日期选择器。

问题是这样的:

我认为问题在于每次启用过滤器时,以下内容div都会附加到 DOM 中,并且在禁用过滤器时永远不会删除。

<div uib-datepicker-popup-wrap=""
     ng-model="date"
     ng-change="dateSelection(date)"
     template-url="uib/template/datepickerPopup/popup.html"
     class="ng-pristine ng-untouched ng-valid ng-scope ng-empty ng-valid-date-disabled"
>
    <!-- ngIf: isOpen -->
</div>
Run Code Online (Sandbox Code Playgroud)

这是一个简化的plunker: http://plnkr.co/edit/eYZt87j2O6A5xhjHj5ZG
如果我只在其中使用一个日期选择器,我会遇到同样的问题Time Range

任何想法都将不胜感激!不想使用 jQuery。

Mar*_*und 2

我不知道为什么会发生这种情况,但没有 jQuery 的解决方案是使用 document.querySelectorAll() 触发过滤器切换时删除弹出窗口

var elements = document.querySelectorAll("div[uib-datepicker-popup-wrap]");
Array.prototype.forEach.call(elements, function(node) {
     node.parentNode.removeChild(node);
});
Run Code Online (Sandbox Code Playgroud)

笨蛋在这里