function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fred13Fred13 

Lightning Component Questions

I am just starting through the Lightning Components Basics Trailhead.  I have a few questions.  The first is, how do you pass data or get data to a component?  For example, I am working on the Handle Actions And Conrollers module.  I built the 'campingListItem Component and Controller but there is no data that shows when I launch the component.  Maybe I'm not there yet but I'm confused how you pass data to the component.

The second question I have is specifically about the challenge for the 'Handle Actions and Controllers" Module.  I completed it successfully, but I'm not sure if what I have is the most efficent way to go about it.  I am pasting my controller below.  The first variable is pulling in the button so I can disable it (btnClicked)  The second variable is getting the item and updating fields form that item.

Thank you!!!

Fred

var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
 var a = component.get("v.item",true);
         a.Packed__c = true;
         component.set("v.item",a);
Best Answer chosen by Fred13
Alba RivasAlba Rivas
Hi Fred,

1) Yes, you have to wait for the module in which they explain how to retrieve data from the server. Basically you have to create an @auraenabled method in the server controller, call it from your javascript controller and set the data in the value provider.

2) There are other options that would work, but unfortunately Trailhead only detects that one as valid. Other option could be:

 component.set("v.item.Packed__c",true);

Regards.

All Answers

Alba RivasAlba Rivas
Hi Fred,

1) Yes, you have to wait for the module in which they explain how to retrieve data from the server. Basically you have to create an @auraenabled method in the server controller, call it from your javascript controller and set the data in the value provider.

2) There are other options that would work, but unfortunately Trailhead only detects that one as valid. Other option could be:

 component.set("v.item.Packed__c",true);

Regards.
This was selected as the best answer
Fred13Fred13
Awesome! Thanks so much for taking the time to help me!
Alba RivasAlba Rivas
Sure, would you mind to mark the response as best response? Thanks
Fred13Fred13
Hello, Do you shop from Amazo n? Thanks Fred