Blame view

src/Slot/Slot.js 612 Bytes
3a3ecabe   Imshann   init
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
  class Slot {
      props = {
          content: String,
          context: Object,
      };
  
      useModules = ["$compile"];
  
      watch = {
          content: (newValue) => {
              if (newValue !== undefined) {
                  if (/<[^>]+>/.test(newValue)) {
                      $element.replaceWith(
                          $compile(newValue)(
                              $scope.context ? $scope.context : $scope
                          )
                      );
                  } else {
                      $element.text(newValue);
                  }
              }
          },
      };
      
      constructor() {
  
      }
  }