Understanding Declarative Data Binding

Declarative data binding enables you to bind the attributes of an HTML element to the properties of a JavaScript object. You can take advantage of declarative data binding whenever you want to display data in an HTML page.

Let me start with a simple example. The page in Listing 3.5 displays product details (see Figure 3.5).

Image

FIGURE 3.5 Showing product details with declarative data binding

LISTING 3.5 Simple Declarative Data Binding (dataBinding\dataBinding.html)

<!DOCTYPE html><html><head>    <meta charset="utf-8" />    <title>Chapter03</title>    <!-- WinJS references --> ...

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.