Activity Forums Salesforce® Discussions What is the correct syntax to use <lightning:card> in Salesforce?

  • What is the correct syntax to use <lightning:card> in Salesforce?

    Posted by krati on February 3, 2020 at 6:48 am

    This is my code inside <aura:component>

    <lightning:card footer="Card Footer" title="Hello">
    <aura:attribute name="searchAccountDetails" type="Account"
                       default="{'sobjectType': 'Account',
                                'Name': ''}"/>
    </lightning:card>
    

    when I try to save this without using <lightning:card> there are no errors, but with <lightning:card>, it is throwing an error:

    ERROR: Invalid attribute "name": Source.

    Could some explain why this error is showing?

    Deepak replied 4 years, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Deepak

    Member
    February 3, 2020 at 10:36 am

    Hi Krati,

    If you want to give an attribute name then you have to use aura component. This facility is not provided in Lightning Card, hence throwing an error.

    <aura:component><lightning:card footer="Card Footer" title="Hello"><aura:set attribute="actions"><lightning:button label="New"/></aura:set><p class="slds-p-horizontal_small">Card Body (custom component)</p></lightning:card></aura:component>

     

    This syntax shows what can we do with the lightning card.

    Hope this helps!

    • This reply was modified 4 years, 9 months ago by  Deepak.
    • This reply was modified 4 years, 9 months ago by  Forcetalks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos