Blame view

build/Spin/Spin.js 1.07 KB
3a3ecabe   Imshann   init
1
  import template from "./Spin.html";
81f8a467   Imshann   调整组件前缀
2
  angular.module("esNgAntd").directive("antdSpin", function () {
3a3ecabe   Imshann   init
3
      return {
81f8a467   Imshann   调整组件前缀
4
          controllerAs: "antdSpin",
3a3ecabe   Imshann   init
5
6
7
8
9
10
11
12
          restrict: "E",
          transclude: true,
          replace: true,
          scope: {
              size: "@",
              spinning: "@",
          },
          template: template,
01d139c3   Imshann   feat(space): 实现组件
13
          controller: function ($scope, $element, $attrs) {
3a3ecabe   Imshann   init
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
              this.getContext = function () {
                  return $scope;
              };
  
              $scope.state = {
                  className: [],
                  hasChildren: false,
              };
          },
          link: function ($scope, $element, $attrs, $controllers, $transclude) {
              $scope.state.className = ["ant-spin", "ant-spin-spinning"];
              $scope.state.hasChildren = JSON.stringify($transclude()) !== "{}";
  
              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");
              }
          },
      };
  });