Blame view

build/Spin/Spin.js 1.18 KB
3a3ecabe   Imshann   init
1
  import template from "./Spin.html";
81f8a467   Imshann   调整组件前缀
2
  angular.module("esNgAntd").directive("antdSpin", function () {
033b7802   Imshann   升级spin组件
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    return {
      template: template,
      restrict: "E",
      replace: true,
      transclude: true,
      scope: {
        size: "@",
        spinning: "="
      },
      controller: function ($scope, $element, $attrs) {
        $scope.state = {
          className: [],
          hasChildren: false
        };
      },
      link: function ($scope, $element, $attrs, $controllers, $transclude) {
        [$element, $attrs, $controllers, $transclude].forEach(function (value, key) {
          if ([undefined, null, ""].includes(value)) {
            throw new Error(`${["$element", "$attrs", "$controllers", "$transclude"][key]} parameter of constructor method is required.`);
          }
        });
        $scope.state.className = ["ant-spin", "ant-spin-spinning"];
3a3ecabe   Imshann   init
25
  
033b7802   Imshann   升级spin组件
26
27
        if ($transclude()) {
          let len = $transclude().lenght;
3a3ecabe   Imshann   init
28
  
033b7802   Imshann   升级spin组件
29
30
31
32
          if (len > 0) {
            $scope.state.hasChildren = true;
          }
        }
3a3ecabe   Imshann   init
33
  
033b7802   Imshann   升级spin组件
34
35
36
37
38
39
40
41
42
43
        if ($scope.size === "small") {
          $scope.state.className.splice(1, 0, "ant-spin-sm");
        }
  
        if ($scope.size === "large") {
          $scope.state.className.splice(1, 0, "ant-spin-lg");
        }
      }
    };
  });