How can i condition ng-readonly inside textarea

ng-if is used to hide or show the element based on the condition given. if you want the condition to apply to ng-readonly, you should put it in the ng-readonly attribute:

<textarea 
    class="wm-textarea-notes"
    ng-model="noteEdit.note_value" 
    columns="1"  
    placeholder="Add a note"
    ng-readonly="note.owner_image !== user.image || note.owner_image !== ''">
</textarea> 

That's not what ng-if does. It just creates or removes the element based upon the value.

What you want is to have a scope method that makes those tests, let's call it isReadOnly and have your textarea like this:

<textarea
    class="wm-textarea-notes"
    ng-model="noteEdit.note_value" 
    columns="1"  
    placeholder="Add a note"
    ng-readonly="isReadOnly()"></textarea>

So, somewhere in your controller you have to create that method that will return true or false for that textarea to determine its status.

Tags:

Angularjs