import template from "./Spin.html"; angular.module("esNgAntd").directive("antdSpin", function () { 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"]; if ($transclude()) { let len = $transclude().lenght; if (len > 0) { $scope.state.hasChildren = true; } } 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"); } } }; });