<commit_before>"use strict";

const controller = function controller ($scope, $element, $sce, adsFactory, productsService) {

  $scope.ads = adsFactory;
  $scope.currentAd = $scope.ads[0] || null;

  $scope.products = [];
  $scope.currentProduct = null;
  productsService.get((error, products) => {
    if (error) {
      return alert(`Error loading products (${error}); returning.`);
    }
    $scope.products = products;
    $scope.currentProduct = $scope.products[0] || null;
  });

  // $scope.$watch("currentAd", () => {
  //   $scope.updateHtml();
  // });

  $scope.updateHtml = function updateHtml () {
    $scope.currentAd.updateHtml(
      $sce.trustAsHtml(
        $scope.currentAd.getHtml($scope.currentProduct)
      )
    );
  };
  $scope.updateHtml();

};

module.exports = controller;<commit_msg>Run updateHtml() when async product get completes.<commit_after>"use strict";

const controller = function controller ($scope, $element, $sce, adsFactory, productsService) {

  $scope.ads = adsFactory;
  $scope.currentAd = $scope.ads[0] || null;

  $scope.updateHtml = function updateHtml () {
    $scope.currentAd.updateHtml(
      $sce.trustAsHtml(
        $scope.currentAd.getHtml($scope.currentProduct)
      )
    );
  };

  $scope.products = [];
  $scope.currentProduct = null;
  productsService.get((error, products) => {
    if (error) {
      return alert(`Error loading products (${error}); returning.`);
    }
    $scope.products = products;
    $scope.currentProduct = $scope.products[0] || null;
    $scope.updateHtml();
  });

  // $scope.$watch("currentAd", () => {
  //   $scope.updateHtml();
  // });

};

module.exports = controller;
{'fraction_non_alphanumeric': 0.17378232110643416, 'fraction_numerical': 0.0024052916416115455, 'mean_word_length': 3.3789473684210525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '91016', 'n_tokens_mistral': 530, 'n_tokens_neox': 519, 'n_words': 95}