Skip to content Skip to sidebar Skip to footer

Disable NgOptions Based On NgChange Update Of Value In Array

I'm attempting to disabled options in a select after they've already been selected. This is dependent on the 'perf_no' associated with each 'cusomter_no' as seen in the following c

Solution 1:

Hmm, maybe it's not pretty, but doing its job (plnkr):

    $scope.passMe;

$scope.changedAffiliate = function(selectedItem, cartPerfNo, index, affiliateCustomer_no) {
  if ($scope.passMe) {
    $scope.affiliates.forEach((aff)=>{
      if (aff.perf_no ==  $scope.passMe[0] && aff.customer_no ==  $scope.passMe[2]) {
        selectedItem[$scope.passMe[0]][ $scope.passMe[1]] = aff
      }
    })
    $scope.passMe = null;
  }
  $scope.passMe = [cartPerfNo,index,affiliateCustomer_no]
  $.each($scope.affiliates, function(i) {
    if(this.perf_no === cartPerfNo && this.customer_no === affiliateCustomer_no){
      this['disabled'] = true;
    }
  });

}

It's based on fact that changedAffiliate will run 1 additional time after being disabled.


Post a Comment for "Disable NgOptions Based On NgChange Update Of Value In Array"