2017-02-09 120 views
0

我正在使用Angular UI Bootstrap Popover,但我無法在外部點擊時關閉它。我正在使用outsideClick觸發器(popover-trigger =「outsideClick」)爲什麼這不起作用?uib-popover不關閉外部點擊

<button uib-popover-template="'myPopoverTemplate.html'" 
    popover-placement="right"class="btn btn-default" 
    popover-trigger="outsideClick">Click Me</button> 

PLUNKER

編輯: 這適用於UI的自舉1.x.x(例如1.3.3)。這在2.x.x中不受支持嗎?

回答

0

這是因爲用戶界面的自舉2.xx的你要做的:

popover-trigger="'outsideClick'">Click Me</button> 

或者使用類似

$scope.myTrigger = "outsideClick" then 
popover-trigger="myTrigger">Click Me</button> 

由於@AngularPlayer

1

該問題出現在您的cdn文件中。檢查工作的代碼如下─

<!doctype html> 
<html ng-app="ui.bootstrap.demo"> 

<head> 
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script> 
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script> 
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.5.js"></script> 
    <script src="example.js"></script> 
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> 


</head> 

<body > 
    <div ng-controller="PopoverDemoCtrl"> 
    <h1>Popover Test</h1> 

    <button uib-popover-template="'myPopoverTemplate.html'" 
      popover-placement="right" 
      class="btn btn-default" popover-trigger="outsideClick" 
      > 
     Click Me 
     </button> 


    <script type="text/ng-template" id="myPopoverTemplate.html"> 

     <label> Why does this popover not close on outside click? </label> 
    </script> 
    </div> 
</body> 

</html> 
+0

ui-bootstrap 2.xx不支持這個嗎? –

+0

沒有它的唯一支持ui-bootstrap 1.xx –

+0

不根據https://angular-ui.github.io/bootstrap/ 上的文檔「外部觸發器會導致彈出窗口切換點擊,並隱藏當其他東西被點擊時。「 –