Blame view

build/List/List.js 995 Bytes
3a3ecabe   Imshann   init
1
  import template from "./List.html";
81f8a467   Imshann   调整组件前缀
2
  angular.module("esNgAntd").directive("antdList", function ($compile) {
3a3ecabe   Imshann   init
3
      return {
81f8a467   Imshann   调整组件前缀
4
          controllerAs: "antdList",
3a3ecabe   Imshann   init
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
          restrict: "E",
          transclude: true,
          replace: true,
          scope: {
              header: "@",
              footer: "@",
              dSource: "=",
              renderItem: "&",
              context: "=",
          },
          template: template,
          link: function ($scope, $element, $attrs, $controllers, $transclude) {
              let container = $element[0].querySelector(".ant-list-items");
  
              if ($scope.dSource) {
                  let items = $scope.dSource.map(function (item) {
                      return $scope.renderItem({
                          item,
                      });
                  });
                  container.innerHTML = items
                      .join("")
                      .replace(/\$scope/g, "context");
                  $compile(container)($scope);
              }
          },
      };
  });