Blame view

build/Radio/Radio.js 1.16 KB
3a3ecabe   Imshann   init
1
2
  import template from "./Radio.html";
  import style from "antd/lib/radio/style/index.css";
81f8a467   Imshann   调整组件前缀
3
  angular.module("esNgAntd").directive("antdRadio", function (esNgAntd) {
3a3ecabe   Imshann   init
4
      return {
81f8a467   Imshann   调整组件前缀
5
          controllerAs: "antdRadio",
3a3ecabe   Imshann   init
6
7
8
9
10
11
12
13
14
          restrict: "E",
          transclude: true,
          replace: true,
          scope: {
              value: "@",
              checked: "@",
              disabled: "@",
          },
          template: template,
81f8a467   Imshann   调整组件前缀
15
          controller: function ($scope, $element, $attrs) {
3a3ecabe   Imshann   init
16
17
18
19
20
21
22
23
24
25
              this.getContext = function () {
                  return $scope;
              };
  
              $scope.state = {
                  checked: false,
              };
  
              $scope.handleClick = function (event) {
                  event.preventDefault();
81f8a467   Imshann   调整组件前缀
26
                  $scope.antdRadioGroup.setValue(event);
3a3ecabe   Imshann   init
27
28
              };
          },
81f8a467   Imshann   调整组件前缀
29
          require: ["?^antdRadioGroup"],
3a3ecabe   Imshann   init
30
          link: function ($scope, $element, $attrs, $controllers, $transclude) {
81f8a467   Imshann   调整组件前缀
31
32
33
              let [antdRadioGroup] = $controllers;
              $scope.antdRadioGroup = antdRadioGroup.getContext();
              $scope.antdRadioGroup.state.childrens.push($scope);
3a3ecabe   Imshann   init
34
35
36
37
              esNgAntd.createStyle("ant-radio", style);
          },
      };
  });