How to disable ion-md-input text field?


#1

I have used ng-disabled=“true” inside <ion-md-input> tag.But it didn’t work.

<ion-md-input placeholder="My Placeholder" highlight-color="assertive" type="text" ng-disabled="true"></ion-md-input>


#2

Ok I Just solved it…I have added attributes for ‘ng-disabled’ property in ionic-md-input.js

var input = element.find(‘input’);
angular.forEach({
‘name’: attr.name,
‘type’: attr.type,
‘ng-value’: attr.ngValue,
‘ng-model’: attr.ngModel,
‘required’: attr.required,
‘ng-required’: attr.ngRequired,
‘ng-minlength’: attr.ngMinlength,
‘ng-maxlength’: attr.ngMaxlength,
‘ng-pattern’: attr.ngPattern,
‘ng-change’: attr.ngChange,
‘ng-trim’: attr.trim,
‘ng-blur’: attr.ngBlur,
‘ng-focus’: attr.ngFocus,
‘readonly’:attr.readOnly,
‘ng-disabled’:attr.disable
}, function(value, name) {
if (angular.isDefined(value)) {
input.attr(name, value);
}
});

Thank U…


#3

Hi! Update! It is not ng-disabled: attr.disable but ng-disabled: attr.ngDisabled


#4

So mine will be /*Start From here*/ var input = element[0].querySelector('.md-input'); angular.forEach({ 'name': attr.name, 'type': attr.type, 'ng-value': attr.ngValue, 'ng-model': attr.ngModel, 'required': attr.required, 'ng-required': attr.ngRequired, 'ng-minlength': attr.ngMinlength, 'ng-maxlength': attr.ngMaxlength, 'ng-pattern': attr.ngPattern, 'ng-change': attr.ngChange, 'ng-trim': attr.trim, 'ng-blur': attr.ngBlur, 'ng-focus': attr.ngFocus, 'readonly':attr.readOnly, 'ng-disabled':attr.ngDisabled, }, function(value, name) { if (angular.isDefined(value)) { input.setAttribute(name, value); } });