Dynamically Add Margin to Ion-Textarea

I am trying to dynamically add margin to an ion-textarea based on a boolean value. What I am trying to achieve is that when textAreaMargin is false remove the default margin and when textAreaMargin is true add the margin back.

I followed the guide on Setting Attributes Dynamically here

Below is my HTML. Any ideas on how to achieve this?

    <ion-textarea [attr.no-margin]="!textAreaMargin ? '' : null" autocorrect="on" [(ngModel)]="editorMsg" (keyup.enter)="sendMsg()" (ionFocus)="_focus()" autosize text-wrap (ionInput)="runTimeChange($event)"></ion-textarea>

Try to use ngClass:

 <ion-textarea [ngClass]="{'no-margin': !textAreaMargin}" autocorrect="on" [(ngModel)]="editorMsg" (keyup.enter)="sendMsg()" (ionFocus)="_focus()" autosize text-wrap (ionInput)="runTimeChange($event)"></ion-textarea>

In your css create a class no-margin with margin: 0 !important as you need to override default margin from Ionic styles.