Is there a way to evaluate a global resource using WinJS directly in my WinJS control options definition, not using data-win-res attribute, because the specific option is a complex object?
Here is what I have:
<div id="CustomControl" data-win-control="My.Custom.NameSpace.Control" data-win-options="{
opt1: 123,
opt2: [
{ prop1: WinJS.Resources.getString('Global_Resource_String').value },
...
}">
</div>
The following attempt to evaluate the resource crashes with an error that the interpreter expects a bracket but instead saw a left parentheses. You can see why I cannot easily generate a setter for this option and data-win-res="{ winControl: {opt2[0].prop1: "Global_Resource_String"} }" doesn’t work for me.
It turns out that inside the
data-win-optionsattribute no function evaluation can be performed and thus the issue with evaluating global resources. If I want to assign a complex option to a global resource I need to do the function evaluation in a global variable and then assign to it like this: