2

I am using template literals to create marup : but it's showing string format. But we can use template literals in Html, please help me.

here is the code

cmp.set('v.colData', `<th aria-label="Name" aria-sort="none" class="slds-is-sortable slds-is-resizable slds-text-title_caps" scope="col">Name</th>`);

Here is the image, But we can use template literals in html

1 Answer 1

3

The framework turns all HTML found in the .cmp file on the server-side into Lightning Components that are rendered into the DOM on the client-side. There is no equivalent automatic conversion of HTML fragments contained in JavaScript, and AFAIK no API to do that.

You can output HTML using the aura:unescapedHtml component and you could dynamically create that component in JavaScript. But components such as lightning:dataTable do not at present allow you to inject other components into cells.

Best to stick to the patterns that are documented and that have examples: the framework is opinionated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .