import CartBase from './base/cart-base.js';

class CartBlogListCtrl extends CartBase {
  constructor($scope, ...args) {
    super(...args);
    this.logInit('CartBlogListCtrl');

    this.$scope = $scope;

    this.postList = [];

    this.init();
  }

  init() {

    if (!this.apiService.isDataInitialized()) {
      // loading animation

      this.apiService.dataInit().then(
        () => {
          // end loading animation??
          this.convertPostDataToViewArr(this.apiService.postMap);
        },
        (error) => {
          // end loading animation??
          this.msgService.error(error);
        }
      );
    } else {
      this.convertPostDataToViewArr(this.apiService.postMap);
    }

  }

  categoryGetTitleViaUuid(uuid) {
    let name = 'N/A';

    if (this.apiService.categoryMap.has(uuid)) {
      name = this.apiService.categoryMap.get(uuid).title;
    }

    return name;
  }

  convertPostDataToViewArr(postMap) { // pagination??
    this.$scope.$apply(() => { // fix the issue: postList updated but data binding not triggered
      for (let [, post] of postMap) {
        //noinspection JSUnusedAssignment
        this.postList.push(post);
      }
    });
  }
}

CartBlogListCtrl.$inject = ['$scope', ...CartBase.$inject];

export default CartBlogListCtrl;

@@ -101,16 +101,26 @@
 ($scope,
+ $timeout,
  ...args
@@ -207,16 +207,46 @@
  $scope;
+%0A    this.$timeout = $timeout;
 %0A%0A    th
@@ -990,24 +990,98 @@
 agination??%0A
+    this.$timeout(() =%3E %7B // fix the issue: $digest already in progress%0A  
     this.$sc
@@ -1171,16 +1171,18 @@
 d%0A      
+  
 for (let
@@ -1201,24 +1201,26 @@
  postMap) %7B%0A
+  
         //no
@@ -1253,24 +1253,26 @@
 ent%0A        
+  
 this.postLis
@@ -1287,25 +1287,37 @@
 ost);%0A      
-%7D
+  %7D%0A      %7D);
 %0A    %7D);%0A  %7D
@@ -1357,16 +1357,28 @@
 $scope',
+ '$timeout',
  ...Cart

Use $timeout to make $apply functions go to the next digest, to prevent "$digest already in progress".