Spin.js
1.07 KB
import template from "./Spin.html";
angular.module("esNgAntd").directive("antdSpin", function () {
return {
controllerAs: "antdSpin",
restrict: "E",
transclude: true,
replace: true,
scope: {
size: "@",
spinning: "@",
},
template: template,
controller: function ($scope, $element, $attrs) {
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");
}
},
};
});