角度ui-bootstrap popover不起作用

时间:2016-12-29 09:41:42

标签: angularjs angular-ui-bootstrap popover

我得到了一个使用角度'ng-repeat'生成的列表,我希望如果单击一个项目,它将弹出一个弹出框以显示一些信息。我试了好几次,但似乎不行。 看看plunker a list demo in plunker 我的代码

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script type="text/javascript" charset="UTF-8" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
  <script data-require="ui-bootstrap@0.4.0" data-semver="0.4.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.4.0.min.js"></script>
  <script src="controller.js"></script>
</head>

<body>
  <div ng-app="my-app" ng-controller="controller">
    <div class="row">
      <div class="col-xs-12" style="text-align:center;">
        <h2>Here is a list a weapons</h2>
      </div>
    </div>
    <div class="row">
      <div class="col-xs-12" ng-repeat="item in weaponItems" ng-click="selectItem()" uib-popover-template="'popover.html'" popover-append-to-body="true" popover-trigger="none" popover-enable="item === selectedItem" popover-open="isOpen === true" popover-placement="left-top">
        <div class="col-xs-6">
          <div class="panel" style="text-align:center;">
            <img src="{{item.img}}" height="120px" width="auto">
          </div>
        </div>
        <div class="col-xs-6">
          <div class="panel">
            <div class="panel-body" style="min-height:120px;">
              <div><b>Category:</b>&nbsp;{{item.title}}</div>
              <p><b>Desc:</b>&nbsp;{{item.desc}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>

1 个答案:

答案 0 :(得分:0)

我在这里添加了示例代码..

你在角度之前加载了ui-bootstrap,所以它失败了(我在angular.js之后放了ui-bootstrap):

<script src="https://code.angularjs.org/1.5.5/angular.js" data-semver="1.5.5" data-require="angularjs@1.5.5"></script>
<script data-require="ui-bootstrap@*" data-semver="1.3.2" src="https://cdn.rawgit.com/angular-ui/bootstrap/gh-pages/ui-bootstrap-tpls-1.3.2.js"></script>

没有调用datepicker指令,因为它需要&#34; uib - &#34; (注意uib-datepicker):

<button popover-placement="bottom" uib-popover-template="'calendar.html'" popover-trigger="click"><h1>Hello Plunker!</h1></button>

还没有调用datepicker指令,因为它需要&#34; uib - &#34; (注意uib-datepicker):

<script id="calendar.html" type="text/ng-template">
  <uib-datepicker ng-model="date" show-weeks="false"></datepicker>
</script>

然后检查output ..