Browse Source

Use controllerAs syntax

Follow https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y032 guide
and use ControllerAs syntax
Fix typo
jmacura 5 năm trước cách đây
mục cha
commit
836e81eb38
3 tập tin đã thay đổi với 9 bổ sung8 xóa
  1. 2 2
      src/adjuster/adjuster.service.js
  2. 6 5
      src/app.js
  3. 1 1
      src/index.html

+ 2 - 2
src/adjuster/adjuster.service.js

@@ -50,7 +50,7 @@ export class AdjusterService {
           this.nutsCodeRecordRelations[a.code] = a;
         });*/
         nuts.nuts3Source.forEachFeature((feature) => {
-          // Pair feature with its clustering data
+          // Pair each feature with its clustering data
           const featureData = clusterData.find(
             (item) => item['nuts_id'] === feature.get('NUTS_ID')
           );
@@ -63,7 +63,7 @@ export class AdjusterService {
         const clusters = [];
         for (const region of clusterData) {
           if (!clusters.includes(region['km25.cluster'])) {
-            clusters.push(region['km2.cluster']);
+            clusters.push(region['km25.cluster']);
           }
         }
         this.clusters = clusters;

+ 6 - 5
src/app.js

@@ -131,8 +131,8 @@ angular
     return {
       template: HsCore.hslayersNgTemplate,
       /* link: function (scope, element) {
-      HsCore.fullScreenMap(element);
-     } */
+        HsCore.fullScreenMap(element);
+      } */
     };
   })
   .value('HsConfig', {
@@ -186,8 +186,9 @@ angular
     PraAdjusterService
   ) {
     'ngInject';
-    $scope.HsCore = HsCore;
-    $scope.panelVisible = HsLayoutService.panelVisible;
+    const vm = this;
+    vm.exists = HsCore.exists;
+    vm.panelVisible = HsLayoutService.panelVisible;
     HsLayoutService.sidebarRight = false;
     // HsLayoutService.sidebarToggleable = false;
     // HsCore.singleDatasources = true;
@@ -196,7 +197,7 @@ angular
     $scope.$on('scope_loaded', function (event, args) {
       if (args === 'Sidebar') {
         const el = angular.element(
-          '<pra.adjuster hs.draggable ng-if="HsCore.exists(\'pra.adjuster\')" ng-show="panelVisible(\'adjuster\', this)"></pra.adjuster>'
+          '<pra.adjuster hs.draggable ng-if="vm.exists(\'pra.adjuster\')" ng-show="vm.panelVisible(\'adjuster\', this)"></pra.adjuster>'
         )[0];
         HsLayoutService.panelListElement.appendChild(el);
         $compile(el)($scope);

+ 1 - 1
src/index.html

@@ -15,7 +15,7 @@
 </head>
 
 <body>
-  <div hs ng-app="hs" ng-controller="MainController" style="height: 100vh;"></div>
+  <div hs ng-app="hs" ng-controller="MainController as vm" style="height: 100vh;"></div>
   <% for (var js in htmlWebpackPlugin.files.js) { %>
     <script type="application/javascript" src="<%= htmlWebpackPlugin.files.js[js] %>"></script>
   <% } %>