Blame view

build/Space/Space.js 1.45 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
              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);
                      }
                  }
              }
3a3ecabe   Imshann   init
43
44
45
          },
      };
  });