ExamGecko
Question list
Search
Search

List of questions

Search

Question 9 - Certified B2B Commerce Administrator discussion

Report
Export

A developer needs to create an event listener on a parent component 04m 49s programmatically. With the script below, what should replace the text

<EVENT_LISTENER_LINE>?

A.
this.template.addEventListener(this.handleNotification);
Answers
A.
this.template.addEventListener(this.handleNotification);
B.
this.template.addEventListener('notification', this.handleNotification);
Answers
B.
this.template.addEventListener('notification', this.handleNotification);
C.
this.template.addEventListener(handleNotification);
Answers
C.
this.template.addEventListener(handleNotification);
D.
addEventListener('notification, this.handleNotification);
Answers
D.
addEventListener('notification, this.handleNotification);
Suggested answer: B

Explanation:

The correct answer is B. this.template.addEventListener('notification', this.handleNotification); because the event listener needs to be created on the parent component programmatically. The event listener should be added to the template of the parent component, and the event type should be 'notification'. The event listener should also have a callback function, which is handleNotification in this case.Reference: [Create a Lightning Web Component]

asked 23/09/2024
JAVIER MALDONADO
31 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first