[Fixed] How to conditionally align text with ngStyle


I have been trying to conditionally align some text with ngStyle, but unsuccessfully thus far.

Here’s the code I’ve developed so far:

<div [ngStyle]="{'display':totalRegisters<=10 ? 'inline-block; text-align: right; width: 100%' : null}">

If someone can help out, I’d much appreciate it


I think you should use ngClass.

  1. Place your alignment style into css class
  2. Use ngClass, example : <div [ngClass]="{'my-class': totalRegisters <= 10}">

More on Angular documentation

Leave a Reply

(*) Required, Your email will not be published