Col.js 1.79 KB
/**
 * 列
 */
import template from "./Col.html";
import style from "antd/lib/grid/style/index.css";
angular.module("esNgAntd").directive("antdCol", function (esNgAntd) {
    return {
        controllerAs: "antdCol",
        restrict: "E",
        transclude: true,
        replace: true,
        scope: {
            span: "@",
        },
        template: template,
        controller: function ($scope, $element, $attrs) {
            this.getContext = function () {
                return $scope;
            };

            $scope.state = {
                className: ["ant-col"],
            };
        },
        require: ["?^antdRow"],
        link: function ($scope, $element, $attrs, $controllers, $transclude) {
            let [antdRow] = $controllers;
            esNgAntd.createStyle("ant-grid", style);
            $element[0].removeAttribute("ng-style");
            $element[0].removeAttribute("ng-transclude");
            $element[0].removeAttribute("ng-class");
            $element[0].removeAttribute("span");

            if (antdRow) {
                $scope.antdRow = antdRow.getContext();
            }

            if ($scope.span) {
                $scope.state.className.push("ant-col-" + $scope.span);
            } // if (this.props.xs) {
            //     this.state.className.push("col-xs-" + this.props.xs);
            // }
            // if (this.props.sm) {
            //     this.state.className.push("col-sm-" + this.props.sm);
            // }
            // if (this.props.md) {
            //     this.state.className.push("col-md-" + this.props.md);
            // }
            // if (this.props.lg) {
            //     this.state.className.push("col-lg-" + this.props.lg);
            // }
            // this.state.className = this.state.className.join(" ");
        },
    };
});