Modal.js 1.24 KB
import template from "./Modal.html";
import style from "antd/lib/modal/style/index.css";
angular.module("esNgAntd").directive("esModal", function (esNgAntd) {
    return {
        controllerAs: "esModal",
        restrict: "E",
        transclude: true,
        replace: true,
        scope: {
            visible: "@",
            title: "@",
            okText: "@",
            cancelText: "@",
            onOk: "&",
            onCancel: "&",
            width: "@",
            footer: "@",
        },
        template: template,
        controller: function ($scope, $element) {
            this.getContext = function () {
                return $scope;
            };

            $scope.state = {
                width: $scope.width || 416,
                okText: $scope.okText || "确定",
                cancelText: $scope.cancelText || "取消",
            };

            $scope.handleClose = function () {
                if (typeof $scope.onCancel === "function") {
                    $scope.onCancel();
                }
            };
        },
        link: function ($scope, $element, $attrs, $controllers, $transclude) {
            $element[0].removeAttribute("title");
            esNgAntd.createStyle("ant-modal", style);
        },
    };
});