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
sai teja 69sai teja 69 

how to open an LWC compenent on button click on another lwc component?

I need to open LWC component when i click on "Edit" button on another LWC component. I have one LWC component with some buttons on case detail page. When i click on the edit button an another edit lwc component should be open with the same record id context.

I have wrote this below function on 'Edit' button onclick LWC.   In url it is coming as "lightning/cmp/c%3AEditCaseButtonOverride" and error This page isn't available in Salesforce Lightning Experience or mobile app.
navigateToEditComponent() {
        this[NavigationMixin.Navigate]({
            "type": "standard__component",
            "attributes": {
                componentName: "c:EditCaseButtonOverride",
                recordId :this.recordId   
            }   
        });
    }



case edit page
Ravi Dutt SharmaRavi Dutt Sharma
In LWC, there is no equivalent of $A.createComponent which is present in Aura. The possible solution to your case is to create branches on the template and only load them when a certain condition is meet.
 
<template>
	<-- Show original component inside this -->
    <div if:true={something}>Conditional Code</div>
    <!-- Show the component on Edit inside this -->
    <div if:false={something}>Conditional Code</div>
</template>