0

I have a textarea and I want to hide the text of the textarea based on a condition

`<textarea class="form-control" 
  [ngClass]="{'pointer-events-none cursor-disabled' :  
  model.userPrivilage.canNewButNotEdit() }" 
  [(ngModel)]="model.repSetUp.DESCR" name="DESCR">
</textarea>`
1
  • 1
    if the value will be empty & text area will be disabled then what is the point of showing it to the user? Simply hide that control. Commented Jun 24, 2019 at 5:39

1 Answer 1

1

You can do two things either disable text area or hide text area on condition, I am giving both use as you want :

<-- Disable textarea -->
<textarea class="form-control" 
  [disabled]="model.userPrivilage.canNewButNotEdit()"
  [(ngModel)]="model.repSetUp.DESCR" name="DESCR">
</textarea>

<-- hide textarea -->
<textarea class="form-control" 
  [ngClass]="{'hide 
  model.userPrivilage.canNewButNotEdit() }" 
  [(ngModel)]="model.repSetUp.DESCR" name="DESCR">
</textarea>

<-- hide text on codition -->
<textarea class="form-control" 
  [value]="(model.userPrivilage.canNewButNotEdit() ? '' : model.repSetUp.DESCR)"
  [(ngModel)]="model.repSetUp.DESCR" name="DESCR">
</textarea>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.