How can I install ng-readonly inside textarea

I am looking for a way to install ng-readonlyinside an operator ng-if.. I tried this in several ways, this is my latest version.

ng-if="note.owner_image === user.image "  ng-readonly="false"

need an assistant.

<textarea 
                  class="wm-textarea-notes"
                  ng-model="noteEdit.note_value" 
                  columns="1"  
                  placeholder="Add a note"
                  ng-readonly="true"
              ng-if="note.owner_image === user.image "  ng-readonly="false"
              ng-if="note.owner_image === "" "  ng-readonly="false


                  ></textarea> 
+4
source share
2 answers

ng-if is used to hide or show an element based on a given condition. 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> 
+8
source

This is not what it does ng-if. It simply creates or deletes an element based on the value.

What you want is to have a scope method that does these tests, call it isReadOnlyand have yours textarealike this:

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

, - , true false textarea, .

+2

All Articles