1

I've got a lightning:card element that has the name of a record as its title and shows some key info of it in the body. I'd like the title to be a link to the record page of the record. I can't just put the tags inside the title, it won't let me. Is there any way to do that or am I out of luck there?

<lightning:card title="{!v.record.name}" iconName="standard:scan_card">
    <!-- record fields go here -->
</lightning:card>
6

I have not tried this myself, created on the fly from this link, but should work

<lightning:card iconName="standard:scan_card">
    <aura:set attribute="title">
        <a href="http://www.yahoo.com">{!v.myTitleName}</a>
    </aura:set>
    <!-- actions and body markup here -->
</lightning:card>
2

Note that Anchor Tag: <a> should not use href's according to the documentation (for your specific use case), and you should instead leverage native events such as force:navigateToSObject to redirect users towards record's as follows:

in your component:

<a onclick="{!c.handleClick}">link to record</a></p>

controller.js

({
    handleClick: function (component, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": component.get("v.recordId")
        });
        navEvt.fire();
    }
})
0

You can just add anchor tag before the lightning card tag.

<a href="www.google.com">
     <lightning:card title="{!v.record.name}" iconName="standard:scan_card">
        <!-- record fields go here -->
     </lightning:card>
</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.