Blame view

example/popover.html 2.21 KB
3a3ecabe   Imshann   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  <!DOCTYPE html>
  <html>
  
  <head>
      <meta charset="UTF-8" />
      <title></title>
      <link href="https://cdn.staticfile.org/antd/3.26.9/antd.css" rel="stylesheet" />
      <style>
  
      </style>
  </head>
  
  <body>
      <div ng-app="essa" ng-controller="mainCtrl">
          <div class="container" style="margin: 200px">
              <es-popover placement="bottom" content="{{content}}" context="context">
                  <button>Hover me</button>
              </es-popover>
              <es-popover placement="top" content="{{content}}" context="context">
                  <button>Top</button>
              </es-popover>
              <es-popover style="position: fixed; left: 200px; top: 200px" placement="top" content="{{content}}" context="context" get-popup-container="handlePopupContainer" id="test">
                  <button>Fixed</button>
              </es-popover>
          </div>
      </div>
      <script src="https://cdn.staticfile.org/angular.js/1.2.28/angular.min.js"></script>
      <script src="https://cdn.staticfile.org/jquery/3.3.0/jquery.min.js"></script>
      <script>
          angular
              .module("essa", [])
              .controller("mainCtrl", function ($scope) {
                  $scope.context = $scope;
                  $scope.dataSource = [{
                      id: 1,
                      name: "aaa"
                  },
                  {
                      id: 2,
                      name: "bbb"
                  }]
                  $scope.handleAbc = function() {
                      alert(123123);
                  }
                  $scope.renderItem = function (item) {
                      return `<es-list-item>
                          <span>${item.name}</span>
                          <button ng-click="$scope.handleAbc()">Link</button>
                      </es-list-item>`;
                  }
                  $scope.content = `<es-list d-source="$scope.dataSource" render-item="$scope.renderItem(item)" context="context"></es-list>`;
                  // $scope.content = `<button ng-click="handleAbc()">1324123</button>`;
  
                  $scope.handlePopupContainer = function() {
                      return document.querySelector("#test");
                  }
              });
      </script>
      <script src="../dist/ng-antd.bundle.js"></script>
  </body>
  
  </html>