2092c4d5
Imshann
优化
|
1
|
import template from "./Button.html";
|
50f4289a
Imshann
优化Form组件
|
2
|
import style from "antd/lib/button/style/index.css";
|
2092c4d5
Imshann
优化
|
3
4
5
6
7
8
9
10
11
12
13
|
angular.module("esNgAntd").directive("antdButton", ["esNgAntd", function (esNgAntd) {
return {
template: template,
restrict: "E",
replace: true,
transclude: true,
scope: {
type: "@",
size: "@",
htmlType: "@",
ghost: "=",
|
ddd373d9
Imshann
优化Card组件
|
14
|
loading: "="
|
2092c4d5
Imshann
优化
|
15
|
},
|
29558aa1
Imshann
优化
|
16
|
controller: function ($scope, $element) {
|
2092c4d5
Imshann
优化
|
17
18
19
20
21
22
23
24
25
26
27
|
$scope.state = {
disabled: null,
className: ""
};
$scope.watch = {
loading: newVal => {
if (newVal !== undefined) {
if (newVal === "true") {
$scope.state.className += " ant-btn-loading";
} else {
$scope.state.className = $scope.state.className.replace(" ant-btn-loading", "");
|
3a3ecabe
Imshann
init
|
28
|
}
|
2092c4d5
Imshann
优化
|
29
30
31
32
|
}
}
};
},
|
50f4289a
Imshann
优化Form组件
|
33
|
link: function ($scope, $element) {
|
2092c4d5
Imshann
优化
|
34
|
esNgAntd.createStyle("ant-btn", style);
|
ddd373d9
Imshann
优化Card组件
|
35
|
let className = ["ant-btn"];
|
3a3ecabe
Imshann
init
|
36
|
|
2092c4d5
Imshann
优化
|
37
38
39
|
if ($scope.type) {
className.push("ant-btn-" + $scope.type);
}
|
3a3ecabe
Imshann
init
|
40
|
|
2092c4d5
Imshann
优化
|
41
42
43
|
if ($scope.size && ["lg", "sm", "xs"].includes($scope.size)) {
className.push("ant-btn-" + $scope.size);
}
|
3a3ecabe
Imshann
init
|
44
|
|
2092c4d5
Imshann
优化
|
45
46
47
|
if ($scope.ghost) {
className.push("ant-btn-background-ghost");
}
|
3a3ecabe
Imshann
init
|
48
|
|
2092c4d5
Imshann
优化
|
49
|
$scope.state.className = className.join(" ");
|
3a3ecabe
Imshann
init
|
50
|
|
2092c4d5
Imshann
优化
|
51
52
53
54
55
56
|
if ($scope.htmlType) {
$element[0].setAttribute("type", $scope.htmlType);
}
}
};
}]);
|