I am using this field for an edit view and a create view
<input data-ng-model="userInf.username" class="span12 editEmail" type="text" placeholder="[email protected]" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}" required />
in the controller I have this code to disable the input element:
function($rootScope, $scope, $location, userService) { //etc $(".editEmail" ).attr("disabled", disable); // no idea how to do in angular }
Please help.
We can easily disable input box(textbox,textarea) using disable attribute to “disabled”. $('elementname'). attr('disabled','disabled'); To enable disabled element we need to remove “disabled” attribute from this element.
Essentially what you really need is to implement a toggling function that changes a boolean type variable whenever the radio button is clicked. Then bind this variable to the disabled attribute of the input text box.
Use ng-disabled or a special CSS class with ng-class
<input data-ng-model="userInf.username" class="span12 editEmail" type="text" placeholder="[email protected]" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}" required ng-disabled="{expression or condition}" />
You need to use ng-disabled directive
<input data-ng-model="userInf.username" class="span12 editEmail" type="text" placeholder="[email protected]" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}" required ng-disabled="<expression to disable>" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With