It is possible to concatenate strings and variables in a Value
?
I want something like this:
<Text Value="Something: {varFromJS}" />
Thanks!
It is possible to concatenate strings and variables in a Value
?
I want something like this:
<Text Value="Something: {varFromJS}" />
Thanks!
Currently that’s not possible at the moment, but you can use Observable
's map
function to do this if your text is already in an Observable
(https://www.fusetools.com/learn/fusejs#ref-map), for example:
var varFromJS = new Observable("awesome");
var prettified = varFromJS.map(function(x) {
return "Something: " + x;
});
Which would show Something: awesome
Thanks Jake! But if varFromJS
changes, prettified
should be an Observable also if I use it in the UX? Or not?
That’s correct, but calling map
on an Observable returns a new Observable, so prettified
is already an Observable. Just bind to that instead of the original one, and you’re all set