LWC Basics
LWC Basics
Step4---->
SCRATCH ORGS-->
Allows development and testing in seperate environments.
They are disposable units.
They are temporary orgs.
max days(30 days).
Step5--->
Dev Hub--->are those salesforce orgs which allows us to create scratch orgs.
Goto--->Salesforce org--->set up-->dev hub-->enable dev hub.
**Once you will enable it it will not disable again.
TRAILHEAD
https://trailhead.salesforce.com/en/content/learn/trails/build-lightning-web-
components
------------->JAVASCRIPT PROPERTIES<------
(Dynamic binding)
<template>
<h1 style="color:whitesmoke">Welcome {welcomename} TO LWC COMPONENTS</h1>
<lightning-input label="Enter Your Name" onchange={showmessage}></lightning-input>
</template>
JS
import { LightningElement } from 'lwc';
welcomename;
showmessage(event)
{
this.welcomename=event.target.value;
}
------------->Calculator In LWC<----------------------------------
<template>
<h1 style="color:yellow;background-color:turquoise">CALCULATOR DEMO</h1>
<lightning-input label="First Number" onchange={num1}></lightning-input>
<br/>
<lightning-input label="Enter Second Number" onchange={num2}></lightning-input>
<br/>
<lightning-button label="sum" onclick={calculate}></lightning-button>
<lightning-button label="sub" onclick={calculate}></lightning-button>
<lightning-button label="multi" onclick={calculate}></lightning-button>
<lightning-button label="divide" onclick={calculate}></lightning-button>
js File
import { LightningElement } from 'lwc';
n1;
n2;
result;
num1(event)
{
this.n1=event.target.value;
}
num2(event)
{
this.n2=event.target.value;
}
calculate(event)
{
var l=event.target.label;
if(l=='sum')
{
this.result=parseInt(this.n1)+parseInt(this.n2);
}
else if(l=='sub')
{
this.result=parseInt(this.n1)-parseInt(this.n2);
}
else if(l=='multi')
{
this.result=parseInt(this.n1)*parseInt(this.n2);
}
else if(l=='divide')
{
this.result=parseInt(this.n1)/parseInt(this.n2);
}
}
}
}
@AuraEnabled(cacheable=true)
public static list<account> allaccounts()
{
return [select name,type from account];
}
}
swati@almamate.in
swatinagpal52@gmail.com
JS File
import { LightningElement,wire } from 'lwc';
HTML File
<template>
<h1 style="color:yellow">View Accounts Name</h1>
<template for:each={accounts.data} for:item="con">
<div key={con.Id}>
<lightning-card title={con.Name}>
{con.Type}
</lightning-card>
</div>
</template>
</template>