Declarative Data Binding and Binding Converters
Binding converters enable you to transform the value of a property when using the property in a data-win-bind
attribute.
There are all sorts of situations in which a binding converter is useful. For example, formatting dates and times or hiding or displaying content depending on a property value. Whenever you need to alter a JavaScript property value before displaying it, use a binding converter.
Imagine, for example, that you want to display the text On Sale!
only when a product is on sale. The page in Listing 3.13 displays two products (see Figure 3.9). It uses a binding converter to hide or display the contents of a DIV element that contains the text On Sale!
Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.