01d139c3
Imshann
feat(space): 实现组件
|
1
2
3
|
import template from "./Space.html";
import style from "antd/lib/space/style/index.css";
angular.module("esNgAntd").directive("esSpace", function (esNgAntd) {
|
3a3ecabe
Imshann
init
|
4
5
6
7
8
9
10
11
12
|
return {
controllerAs: "esSpace",
restrict: "E",
transclude: true,
replace: true,
scope: {
direction: "@",
size: "@",
},
|
01d139c3
Imshann
feat(space): 实现组件
|
13
14
15
16
17
18
19
20
21
22
23
|
template: template,
controller: function ($scope, $element, $attrs) {
this.getContext = function () {
return $scope;
};
$scope.state = {
direction: $scope.direction || "horizontal",
size: $scope.size || 8,
};
},
|
3a3ecabe
Imshann
init
|
24
|
link: function ($scope, $element, $attrs, $controllers, $transclude) {
|
01d139c3
Imshann
feat(space): 实现组件
|
25
26
27
28
29
|
esNgAntd.createStyle("ant-space", style);
$element.removeAttr("ng-class");
$element.removeAttr("ng-style");
let childrens = $transclude();
|
3c86e8de
Imshann
feat(space): 优化组件
|
30
31
|
for (let i = 0; i < childrens.length; i++) {
const children = childrens[i];
|
01d139c3
Imshann
feat(space): 实现组件
|
32
|
|
3c86e8de
Imshann
feat(space): 优化组件
|
33
34
35
36
37
38
|
if (children.nodeType === 1) {
let item = angular
.element("<div>")
.addClass("ant-space-item")
.append(children);
$element.append(item);
|
01d139c3
Imshann
feat(space): 实现组件
|
39
40
|
}
}
|
3a3ecabe
Imshann
init
|
41
42
43
|
},
};
});
|