Reputation: 61
For my website I have a custom directive for some fields, I would like to dynamically change in the directive whether a particular field should be read only or not based on some values.
Is this possible? and if so how?
Upvotes: 0
Views: 122
Reputation: 49
If your custom directive can be used as class i.e,restrict :'C',then
ng-class="{className:[condition]}"
ng-class="{custom-directive:[value =='ABC']}"
Upvotes: 0
Reputation: 699
I don't think a directive is necessary for what you want to do as ng-readonly
can take arguments, you would use it like this;
<input type="search" ng-readonly"variable===true"/>
Hope it helps!
Upvotes: 1