polymerlit-element

*ngIf equivalent in lit-element/polymer


I'm looking to implement condition based HTML in lit-element and need something like *ngIf which Angular provides.

I could render different HTML based on conditions but it will be great if it can be done with condition.


Solution

  • You can use plain Javascript. Explained well in official documentation

    Example:

    ${this.myBool ? html`<p>something</p>` : html`<p>something else</p>`}