Radio.js
1.13 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("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);
},
};
});