How do I do something like this on a text prop of a label. I want the label to change based on the dropdown selection.
if {../Dropdown.props.value} = 0
....
if {../Dropdown.props.value} = 1
...
How do I do something like this on a text prop of a label. I want the label to change based on the dropdown selection.
if {../Dropdown.props.value} = 0
....
if {../Dropdown.props.value} = 1
...
Use an expression binding.
case({../Dropdown.props.value},
1, "A partridge in a pear tree",
2, "Two turtle doves",
3, "Three French hens",
4, "Four calling birds",
5, "Golden rings",
"Unknown 12 Days of Christmas gift"
)
Merry Christmas !
As an aside, you can't write programs in an expression. Think of them like Excel functions. To make your expression work with if
you would need,
if(({../Dropdown.props.value} = 1,
"A partridge in a pear tree",
if({../Dropdown.props.value} = 2,
"Two turtle doves",
if({../Dropdown.props.value} = 3,
"Three French hens",
if({../Dropdown.props.value} = 4,
"Four calling birds",
if({../Dropdown.props.value} = 5,
"Golden rings",
"Unknown 12 Days of Christmas gift"
)))))
It's not pretty!
the comma after "tree" needs to be outside the quotation mark.
Fixed, thanks.
Merry Christmas!