Angularjs : enabled ng-click on disabled input

Viewed 681

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" />
2 Answers

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.

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

Related