Modal.js
1.24 KB
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
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);
},
};
});