LWC Stack is Lightning Web Component tutorial series by Salesforce MVP Kapil Batra. In this series you will find LWC tutorials from beginner to intermediate level.
So if you are working on it or planning to learn LWC then this video series is for you. Let's learn and grow together !
Please check complete code below from LWC Stack EP-19
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <template> <lightning-card title="Get Object Info using Wire" icon-name="utility:user"> <div class="slds-var-m-around_medium"> <div style="padding:10px"> <lightning-input placeholder="Enter API Name" label="Object Name"> </lightning-input> <br/> <lightning-button label="Fetch Metadata" onclick={handleClick}> </lightning-button> <br/> <p>{objectMetadata}</p> </div> </div> </lightning-card> </template> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import { LightningElement,wire } from 'lwc'; import {getObjectInfo} from 'lightning/uiObjectInfoApi'; export default class GetObjectDetails extends LightningElement { objectApiName; @wire(getObjectInfo,{objectApiName : '$objectApiName'}) objectInfo; handleClick(){ this.objectApiName = this.template.querySelector('lightning-input').value; console.log('###Object Name : '+this.objectApiName); } get objectMetadata(){ return this.objectInfo ? JSON.stringify(this.objectInfo.data,null, 10):''; } } |
Checkout complete video tutorial below
0 Comments