import template from "./Radio.html"; import style from "antd/lib/radio/style/index.css"; angular.module("esNgAntd").directive("esRadio", function (esNgAntd) { return { controllerAs: "esRadio", restrict: "E", transclude: true, replace: true, scope: { value: "@", checked: "@", disabled: "@", }, template: template, controller: function ($scope, $element) { this.getContext = function () { return $scope; }; $scope.state = { checked: false, }; $scope.handleClick = function (event) { event.preventDefault(); $scope.esRadioGroup.setValue(event); }; }, require: ["?^esRadioGroup"], link: function ($scope, $element, $attrs, $controllers, $transclude) { let [esRadioGroup] = $controllers; $scope.esRadioGroup = esRadioGroup.getContext(); $scope.esRadioGroup.state.childrens.push($scope); esNgAntd.createStyle("ant-radio", style); }, }; });