Radio.js
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);
},
};
});