Space.js
1.45 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
43
44
45
import template from "./Space.html";
import style from "antd/lib/space/style/index.css";
angular.module("esNgAntd").directive("esSpace", function (esNgAntd) {
return {
controllerAs: "esSpace",
restrict: "E",
transclude: true,
replace: true,
scope: {
direction: "@",
size: "@",
},
template: template,
controller: function ($scope, $element, $attrs) {
this.getContext = function () {
return $scope;
};
$scope.state = {
direction: $scope.direction || "horizontal",
size: $scope.size || 8,
};
},
link: function ($scope, $element, $attrs, $controllers, $transclude) {
esNgAntd.createStyle("ant-space", style);
$element.removeAttr("ng-class");
$element.removeAttr("ng-style");
let childrens = $transclude();
for (const key in childrens) {
if (Object.hasOwnProperty.call(childrens, key)) {
const children = childrens[key];
if (children.nodeType === 1) {
let item = angular
.element("<div>")
.addClass("ant-space-item")
.append(children);
$element.append(item);
}
}
}
},
};
});