0

I'm new to lightning and never used carousel component. My requirement is to display different images by querying from object level and upon clicking on the picture it will call another component and pass a value which will be used as an attribute of the 2nd component.Kindly help.. please find below component ..

apex

public class imagecheckcontact{

@AuraEnabled 
public static List<contact> getcons(){
    return [Select Id,name,sankha__image__c from contact where id in ('00328000014LZcM', '00328000014LZjA')];
}

}

component

<lightning:carousel >
    <aura:iteration items="{!v.conct}" var="con">
        <lightning:carouselImage width="500px" height="600px" src = "{!con.sankha__image__c}" 
                                 description = "First card description."  onclick="{c.navigate}"  header = "{!con.name}" 
                                 >
        </lightning:carouselImage>
    </aura:iteration>
</lightning:carousel>

JS


({
    doInit : function(component, event, helper) {
        var action = component.get("c.getcons"); 
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var retrunRes = response.getReturnValue();
                component.set("v.conct" ,retrunRes );
            }
        });
        $A.enqueueAction(action);
    },
    navigate:function(component, event, helper) {
            var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
            componentDef : "c:Helloworld",
            componentAttributes: {
                contactName : component.get("v.contact.Name")
            }
        });
        evt.fire();
    }

})
  • 1
    We need a bit more than "it's not working, please fix." Please edit your question to describe what's going on, any errors you may be seeing, the data type of sankha__image__c, which environment you're using (Lightning, Lightning Out, etc), and anything else you might think is relevant. Please read about How to Ask and take the tour if you're unfamiliar with how SFSE works. – sfdcfox Feb 11 at 5:33
  • I'm not getting any error. Just the image is not getting displayed..It's coming as a broken image. I'm using lightning environment not lightning out. sankha__image__c data type is Rich Text Area(32768). Please let me know for any question – Sankhadeep Biswas Feb 11 at 16:43
  • I do not understand what is the problem – Itai Shmida Feb 13 at 7:45
  • Scenario : Retirving 4 product records including 3 fields.id, image(richtext field) and name.Displaying image in lightning carousal and also name as the header..Now I want to hold the product id , and pass it as param . Now i'm unable to hold the prod id value as lightning:carousal has no attribute neither aura:id , id or data-attriVal helping me to store the prod id value..Any workaround . – Sankhadeep Biswas Feb 14 at 6:30

Your Answer

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

Browse other questions tagged or ask your own question.