Radio.js 1.16 KB
import template from "./Radio.html";
import style from "antd/lib/radio/style/index.css";
angular.module("esNgAntd").directive("antdRadio", function (esNgAntd) {
    return {
        controllerAs: "antdRadio",
        restrict: "E",
        transclude: true,
        replace: true,
        scope: {
            value: "@",
            checked: "@",
            disabled: "@",
        },
        template: template,
        controller: function ($scope, $element, $attrs) {
            this.getContext = function () {
                return $scope;
            };

            $scope.state = {
                checked: false,
            };

            $scope.handleClick = function (event) {
                event.preventDefault();
                $scope.antdRadioGroup.setValue(event);
            };
        },
        require: ["?^antdRadioGroup"],
        link: function ($scope, $element, $attrs, $controllers, $transclude) {
            let [antdRadioGroup] = $controllers;
            $scope.antdRadioGroup = antdRadioGroup.getContext();
            $scope.antdRadioGroup.state.childrens.push($scope);
            esNgAntd.createStyle("ant-radio", style);
        },
    };
});