0

I have created a new component and I want to be able to pass an image from a static resource and a custom label via aura:attribute. This is what I tried and it does not work. How can I make the image/text to show?

<aura:attribute name="profileImage" type="string" default="Standard_Profile" />
<aura:attribute name="categoryName" type="string" default="Standard_Name" />

<img src="{!$Resource + !v.profileImage}" alt="profile pic"/>
<h3>{!$Label.'categoryName'}</h3>

I am very new to Salesforce.

Fergoso
  • 1,584
  • 3
  • 21
  • 44

1 Answers1

0

Map the values from your custom label and static resource as default values in the attributes and use it in the code

<aura:component implements="flexipage:AvailableForAllPageTypes">
    <aura:attribute name="profileImage" type="string" default="{!$Resource.profileImage}" />
    <aura:attribute name="categoryName" type="string" default="{!$Label.c.categoryName}" />
    
    <!-- Stand-alone static resources image file-->
    <img src="{!v.profileImage}"/>
    
    <!-- custom label -->
    <div>
        {!v.categoryName}
    </div>
</aura:component>
Naveen K N
  • 180
  • 1
  • 11