Swap - ngClass

Code

<button class={"prev " + (this.start === 0? 'disabled' : '')}></button>

Context

Think of this as a button, that is part of a pagination component. If, the user is at the start of the list, then the Previous button i.e. ( button with the class '.prev' ) should be disabled.

With Angular, we would generally use ngClass.

The alternative with StencilJS is to use a Data binding expression, based on the value of the 'start' variable. This then allows you to add as many classes as need be.

Reference

Last updated

Was this helpful?