Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ngclass in Stencil.js

The below is the code in Angular 2. Could someone explain how to use ngclass in Stencil.js.

I have created the component is Angular2. Now trying to recreate the same in Stenciljs:

<div class="inner_holder" [ngClass]="isSelected(day)">
  <div class="col day">{{day.month}}</div>
     <div class="col date">
       <span>{{day.date}}</span>
     </div>
</div>    

TypeScript Code:

isSelected(day) {
  return (day.fullDay === this.selectedDay) ? "active" : "";
 }
like image 627
Praveen Kumar Avatar asked Jun 12 '26 19:06

Praveen Kumar


1 Answers

You can also use following syntax:

<div 
  class={{
    'error': this.hasError,
    'hidden': !this.isOpen
  }}
>
like image 110
fabio_biondi Avatar answered Jun 14 '26 10:06

fabio_biondi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!