2

How can I enabled ng-click on a text input even if the input is disabled?

<input type="text" ng-model="myModel" ng-click="vm.handleClick()" ng-disabled="true" />
1
  • if you really want it. Try trick by class disable, and regex prevent any action input in this Commented Jan 15, 2019 at 8:39

2 Answers 2

2

This is impossible in fact. Each AngularJS directive has its own priority. You may notice that ngDisabled has priority 100, while ngClick set at 0. Moreover, ngDisabled required to set native input disabled attribute, because it does not support interpolation.

Speaking about native input disabled state:

If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire.

Other words - if it is disabled then it is disabled and no events are possible. Otherwise disabled directive would be meaningless.

Sign up to request clarification or add additional context in comments.

Comments

1

make a wrapper and bind ng-click on it. i.e.

<div ng-click='ur_Function()'>
<input type="text" ng-model="myModel"  ng-disabled="true" />
</div>

U can check in your function whether input enabled is true or false and perform accordingly

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.