2

Update

1- IsShopToShowTerminated returns true which is expected but values doesn't reflects in the view.


I have shared angularjs code. There IsShopToShowTerminated is always undefined and doesn't depict the required value.

I think problem is because, it renders first and then value of the IsShopToShowTerminated is changed. After search I am getting more and more confused.

$scope.IsShopToShowTerminated = function(shopTerminationDate) {
  setTimeout(function() {
      debugger;
      if ($scope.IsTerminated($scope.viewCompany.TerminationDate)) {
        return true;
      } else {
        return $scope.IsTerminated(shopTerminationDate);
      }
    },
    0);
}
<td ng-init="isTerminatedValue = IsShopToShowTerminated(shop.TerminatinonDate)">
  {{isTerminatedValue}}
  <div ng-show="isTerminatedValue">
    <i class="fa fa-circle text-danger"></i>
    <small>Terminated</small>
  </div>

  <div ng-show="isTerminatedValue">
    <i class="fa fa-circle text-success"></i>
    <small>Active</small>
  </div>
</td>
Charlie
  • 4,827
  • 2
  • 31
  • 55

1 Answers1

0

You can delay the rendering by adding a ngIf directive that would check the value of isTerminatedValue for undefined.

<td ng-init="isTerminatedValue = IsShopToShowTerminated(shop.TerminatinonDate)">
    <div ng-if="isTerminatedValue">
        {{isTerminatedValue}}
        <div ng-show="isTerminatedValue">
            <i class="fa fa-circle text-danger"></i>
            <small>Terminated</small>
        </div>
        <div ng-show="isTerminatedValue">
            <i class="fa fa-circle text-success"></i>
            <small>Active</small>
        </div>
    </div>  
</td>
NTP
  • 4,338
  • 3
  • 16
  • 24