popover.html 2.21 KB
<!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>