When utilizing
ng-disabled="truthy_scope_variable"
to conditionally disable a text input field in AngularJS, an unexpected behavior occurs. The field is disabled the first time the scope variable is turned from truthy to falsified, but subsequent changes do not enable it as expected. Despite monitoring the variable's change with $watch
and trying to trigger updates with $apply
, the input field remains disabled without any errors logged in the Console.
The scope variable in question is linked to a radio button model, where setting $scope.new_account = true
should enable the input field, but this does not happen as intended. It seems that AngularJS may be overlooking DOM changes or failing to register the modifications properly.
Code snippet from controller:
$scope.new_account = true
Radio buttons binding:
<input type="radio" ng-model="new_account" name="register"
id="radio_new_account" value="true" />
<input type="radio" ng-model="new_account" name="register"
id="radio_existing_account" value="false" />
Text input field with conditional disabling:
<input type="password" ng-disabled="new_account" id="login-password"
name="password" ng-model="password" />
Even if initially set to false
, rendering the field disabled, the issue persists where it fails to re-enable upon changing the scope variable. The root cause of this behavior remains unclear.