【问题标题】:uib-popover unexpectedly closes with "outsideClick" and uib-datepickeruib-popover 使用“outsideClick”和 uib-datepicker 意外关闭
【发布时间】:2016-10-11 05:56:52
【问题描述】:

uib-Popover 使用 popover-template、“outsideClick”触发器和其中的 uib-Datepicker 意外关闭:事实上,当单击 datepicker 本身时,popover 意外关闭。

这里是打开弹出框的按钮:

<div style="text-align:center;">
  <button uib-popover-template="'myPopoverTemplate.html'" popover-title="Popover title" type="button" class="btn btn-default" popover-trigger="outsideClick" popover-placement="bottom" >Open me</button>
</div>

和弹出框模板:

<script type="text/ng-template" id="myPopoverTemplate.html">
    <div class="form-group">
      <uib-datepicker ng-model="dateTime" class="well well-sm"></uib-datepicker>
    </div>
    {{dateTime | date}}
</script>

plnkr 中的完整代码:http://embed.plnkr.co/ESto8dgDbh52g0nl7g03/

这是 angular bootstrap 的错误还是我遗漏了什么?我已经在 angular bootstrap github 上打开了一个问题,你可以在这里关注它: https://github.com/angular-ui/bootstrap/issues/5979

【问题讨论】:

    标签: javascript html angularjs angular-ui-bootstrap


    【解决方案1】:

    我发现这已经是github上的aswered了。

    下面我将分享 angular bootstrap 的主要贡献者之一 wesleycho 的答案:

    您必须手动停止点击事件传播。

    更实际的,你需要添加一个

     ng-click="$event.stopPropagation()"
    

    在 uib-datepicker 的父元素上。

    可以在here(由 wesleycho 自己提供)找到此解决方案的简单示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-29
      • 2020-04-15
      • 2022-08-11
      • 2017-01-20
      • 2017-01-14
      • 2020-05-15
      • 1970-01-01
      相关资源
      最近更新 更多