Disable button on Angular depending on a variable

2

I have a problem, I have an angled condition when my situation is PENDING, it will disable two buttons.

$scope.situacaoParcelaPendente = "PENDENTE";

/*ultimo teste*/
if ($scope.resultSimulacao.ticlaa1VO.dscSituacaoParcela == $scope.situacaoParcelaPendente) {
  //disabilitar btnSimular, etc
  $scope.btnSimular.disabled = true;

} else {
  //habilitar btnSimular
  $scope.btnSimular.disabled = false;
}
    
asked by anonymous 19.11.2015 / 13:48

1 answer

3

You can assign Boolean values to your variable, and in your button in HTML you use the ng-disabled

<input class="btn submit-btn" type="submit" value="Salva" ng-disabled="desabilitaBotao" />

In scopo, you assign true or false to the variable

var desabilitaBotao = $scope.resultSimulacao.ticlaa1VO.dscSituacaoParcela == 'PENDENTE';
$scope.desabilitaBotao = desabilitaBotao;

Whenever the value is true in your variable, the button will be disabled.

    
19.11.2015 / 13:59