Angularjs bootstrap 模型更改后弹出窗口闪烁

Angularjs bootstrap popover blink after model change

我在 table.

中使用 angularjs bootstrap popover

table 是使用 ng-repeat 填充的,如果弹出窗口打开并且我向 table 获取新数据,则弹出窗口会闪烁。

这是一个工作示例 Pknkr

有没有想过如何防止闪烁?

<!doctype html>
<html ng-app="ui.bootstrap.demo">
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.0.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>

<div ng-controller="PopoverDemoCtrl">
  <br/>
  <br/>
  <table>
    <tr ng-repeat="item in list">
      <td>
        <button uib-popover-template="dynamicPopover.templateUrl" 
                popover-is-open="aux.openPopOverId==item.id" 
                ng-click="aux.openPopOverId=item.id" popover-placement="right" type="button" class="btn btn-link">
          Popover
        </button>
      </td>
    </tr>
  </table>

    <script type="text/ng-template" id="myPopoverTemplate.html">
        <div>{{dynamicPopover.content}}</div>
        <div class="form-group">
          <label>Popup Title:</label>
          <input type="text" ng-model="dynamicPopover.title" class="form-control">
        </div>
    </script>
</div>
  </body>
</html>

和js

angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('PopoverDemoCtrl', function ($scope,$interval, $sce) {
  $scope.dynamicPopover = {
    templateUrl: 'myPopoverTemplate.html',
    title: 'Title'
  };

  $scope.list = [{'id':1},{'id':2},{'id':3}];
  $scope.aux = {'openPopOverId':2};

  $scope.updateList = function(){
    $scope.list = [{'id':1},{'id':2},{'id':3}];
  }

  $interval($scope.updateList,500,0);
});

我想这可能对你有帮助,请详细read here..