Here we are going to learn how we can migrate expressions from markup in the Aura component to JavaScript in a Lightning web component.
In the Lightning web component, we can't use expressions in markup (template) but we can use expressions in the Aura component's markup.
If we have to use expressions in Lightning web components then we have to write this expression in LWC JavaScript File and return the result with the help of getter methods as shown below.
Aura:
Syntax:
<aura:if isTrue="{! (!v.isShow? true : false) }">
<div>Conditional Code</div>
</aura:if>
LWC:
Syntax:
<template>
<div if:true={showValues}>Conditional Code</div>
</template>
import { LightningElement } from 'lwc';
export default class MyComponentName {
get showValues() {
return isShow? true : false;
}
}
Reference:
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.migrate_expressions
Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles Bulk Metadata Operations
ReplyDeleteThank you much for sharing this wonderful post.
ReplyDeleteAWS Training in Chennai