0

I have an input text which is disabled by default :

 <input type="text" ng-model="city.name" class="form-control"
                                   disabled
                                   name="name">

But i want to enable it when the input country is not null :

   <input type="text" ng-model="country.name" class="form-control"
                                         >

How can i do this in the angular controller ? i start with something like this in my controller but i dont know how to enable it once the country value is not null

  // Watch if the country value is not null
            $scope.$watch("country.name", function (value) {
                if (value !=null) {
                    // enable the city field
                }
            },true);

Thanks

1 Answer 1

1

You can use ng-disabled without going into the controller:

<input type="text" ng-model="city.name" class="form-control" ng-disabled="!country.name" name="name">
<input type="text" ng-model="country.name" class="form-control">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.