Hello Community - I am working on a component which uses the sling model to get the required values for the properties that is working as expected. My question here is, I need to use the values I received from Sling Model in javascript (Included as a clientlib in the component).
E.g. <sly data-sly-use.productData="com.xxx.aem.models.ProductData"></sly>
${productData.prodDescription @ context='unsafe'} - Can this be used directly used in clientlibs (Not USE API) ?
ClientLibrary:
var prodDetails = '${productData.prodDescription @CONTEXT='unsafe'}';
--------------------------------------------
Or should I assign this in HTL first like: <sly data-sly-test.prodDetails ="${productData.prodDescription @ context='unsafe'}"></sly> and then use it in javascript as below?
var prodDetails = '${prodDetails}'; - I already set the context in HTL, so I didn't use it here.
Also could somebody clarify in which scenario should the context as "scriptString" or "unsafe" be used? As I see both are being used in variable assignment in JS.