function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
moni shamoni sha 

using LWC to show a custom label as link and when clicked shows value from another custom label

Hi All,

Can you please help me in achieving the below requirement using Lightning web component.

To show a custom Label as Link and when clicked it has to show value from another custom Label 

Thanks,
Keerthana.
Maharajan CMaharajan C
Hi Keerthana,

Refer the below code:

Html :
 
<template>
    <div class="slds-p-around_medium">
        <a href="" onclick={handleclick}> {label.label1}  </a>
        <template if:true={bool}>
            <p><lightning-formatted-url value={label.label2} target="_blank"></lightning-formatted-url></p>
        </template>
    </div>
</template>

JS:

I have created the two custom label and named as label1, label2.
import { LightningElement,api } from 'lwc';

import label1 from '@salesforce/label/c.label1';
import label2 from '@salesforce/label/c.label2';
export default class ForumCustomLabelURL extends LightningElement {
    label = {
        label1,
        label2,
    };

    @api bool = false;

    handleclick(event){
        event.preventDefault();
        console.log(' ********* ');
        if(!this.bool)
            this.bool = true;
        //else
        //    this.bool = false;
    }
}

XML:
 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>51.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>


Thanks,
Maharajan.C
​​​​​​​