ExamGecko
Question list
Search
Search

List of questions

Search

Question 212 - Certified B2B Commerce Administrator discussion

Report
Export

Which option is the correct syntax to render a property in a Lightning web component template?

A.
Surround the property with curly braces: {property}
Answers
A.
Surround the property with curly braces: {property}
B.
Surround the property with brackets: [property]
Answers
B.
Surround the property with brackets: [property]
C.
Surround the property with an exclamation point and curly braces: {property}
Answers
C.
Surround the property with an exclamation point and curly braces: {property}
D.
Surround the property with curly braces and exclamation point: {{property}
Answers
D.
Surround the property with curly braces and exclamation point: {{property}
Suggested answer: A

Explanation:

Surround the property with curly braces: {property} because this is the syntax for data binding in a Lightning web component template. Data binding is a way to link a property in a component's template to a property in the component's JavaScript class.When the value of the property changes, the component re-renders and updates the template accordingly1. For example, suppose there is a component that has a name property in its JavaScript class:

// helloWorld.js import { LightningElement, api } from 'lwc';

export default class HelloWorld extends LightningElement { // Declare a public name property @api name = 'World'; }

To render the name property in the component's template, surround it with curly braces:

<!-- helloWorld.html --> <template>

Hello, {name}! </template>

The output will look like this:

Hello, World!

asked 23/09/2024
Adriano Costa
36 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first