Docs (4.0.0)
class Binding method

select

Adds a filter, to use one of the provided values instead of the bound value.

select<U, V>(trueValue: U, falseValue?: V): Binding<U | V>

Summary

This method can be used to substitute the bound value with a fixed value. If the bound value is equal to true (according to the == operator), the value is replaced with the provided trueValue. Otherwise, the value is replaced with the provided falseValue, e.g. for bound undefined, null, false, zero, and empty string values. If falseValue isn’t provided, undefined is used.

Parameters

  • trueValue — The value to be used if the bound value is equal to true
  • falseValue — The value to be used if the bound value is equal to false

Return value

A new binding, typed like both of the given values

Example

// A label that displays (localized) Yes or No
// depending on a property value
ui.label(
  bound("isEnabled").select(strf("Yes"), strf("No"))
)

Related