A developer created a child Lightning web component nested inside a parent Lightning web component. The parent component needs to pass a string value to the child component.
In which two ways can this be accomplished? (Choose two.)
A.
The parent component can use a custom event to pass the data to the child component.
B.
The parent component can invoke a method in the child component.
C.
The parent component can use a public property to pass the data to the child component.
D.
The parent component can use the Apex controller class to send data to the child component.
A and C
Explanation:
A. Custom events are used to communicate between Lightning web components, and can be used to pass data from a parent component to a child component. The parent component can fire a custom event and include the data as a parameter, which the child component can then access.
B. A child component can have public methods that can be invoked from the parent component, but this is not the optimal solution for passing data to the child component because it requires more complex code to handle data passing.
C. Public properties can be used to pass data from a parent component to a child component. The parent component can set a public property on the child component, which the child component can then access.
D. The Apex controller class is used to interact with the server-side database and is not involved in passing data between parent and child components.
Its interesting to know how you can pass custom event frrom parent to child? From child- to parent you can call this.dispatchEvent(new CustomEvent('yourEvent')); See https://trailhead.salesforce.com/content/learn/projects/communicate-between-lightning-web-components
Option D, using the Apex controller class to send data to the child component, is not a valid way to pass data between parent and child components. The Apex controller class can be used to retrieve data from Salesforce, but not to communicate between components.
Therefore, the correct options are A and C.
upvoted 3 times
...
This section is not available anymore. Please use the main Exam Page.CRT-450 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
irina_735
8 months agogovosen887
1 year, 1 month agowlthorn
1 year, 1 month agoirina_735
8 months agotMana
1 year, 2 months ago