[SalesForce] Display a Component as Modal in lightning

  • I have two components
  • Component A : Display's the list of Account, on click of account name it fires a event which passes Accountid to Component B.
  • Component B – It listens the event and Displays the Contact based on the AccountId attribute
  • I want to display Component B on the Modal

Best Answer

So try this. I guess your contacts table will be in somewhere. move all contact table code inside the lightning model tags

check this codes https://www.lightningdesignsystem.com/components/modals/

and when the page loads then set the model display to none.

when you click on any of the account, you may call a controller to get all the associated contacts. once all the contact records received. Just get the model div and change the style display none to block.

This way you show the model.. And

you can use

<div role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal slds-fade-in-open">
 <!--set of your code--> 
  <!--table-->
</div>

here you can see slds-fade-in-open this css with display the model.

.slds-fade-in-close class will hide the model

Related Topic