/** * 表单域 * * @Author: Shann * @LastEditors: Shann * @Date: 2021-07-26 08:53:33 * @LastEditTime: 2021-08-05 14:03:05 * @FilePath: \angular-js-for-bootstrap\src\Essa\FormItem\FormItem.js * @Copyright: Copyright 2021-2021, all rights reserved. Essa.cn */ import template from "./FormItem.html"; angular.module("esNgAntd").directive("antdFormItem", function () { return { controllerAs: "antdFormItem", restrict: "E", transclude: true, replace: true, scope: { name: "@", label: "@", labelCol: "=", wrapperCol: "=", required: "@", }, template: template, controller: function ($scope, $element, $attrs) { this.getContext = function () { return $scope; }; $scope.state = { labelCol: null, wrapperCol: null, }; }, require: ["?^antdForm"], link: function ($scope, $element, $attrs, $controllers, $transclude) { let [antdForm] = $controllers; $scope.antdForm = antdForm.getContext(); if ($scope.labelCol && $scope.labelCol.span) { $scope.state.labelCol = $scope.labelCol.span; } else if ( $scope.antdForm.labelCol && $scope.antdForm.labelCol.span ) { $scope.state.labelCol = $scope.antdForm.labelCol.span; } if ($scope.wrapperCol && $scope.wrapperCol.span) { $scope.state.wrapperCol = $scope.wrapperCol.span; } else if ( $scope.antdForm.wrapperCol && $scope.antdForm.wrapperCol.span ) { $scope.state.wrapperCol = $scope.antdForm.wrapperCol.span; } }, }; });