*ngIf equivalent in lit-element/polymer

Total
5
Shares

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>`}
Leave a Reply

Your email address will not be published. Required fields are marked *