Artful binding.

data-bind

<p>MDV is {{ superlative }}</p> <div> <input type="text" bind-value="superlative" placeholder="Enter superlative"> </div>

{{ superlative }}

bind-value="superlative"

String superlative = ''; main() { }

(Binding image courtesy of http://www.flickr.com/photos/ruthbleakley/3098090721/

Updating awhen the data changes is cool. Updating thewhen the web page changes is even cooler. Read on to learn how to create a live data binding between form fields, data, and your web page with Web Components, Model Driven Views, and Dart (You may want to read Your First Model Driven View with Dart , which contains more information on getting started. This post assumes you've read my previous posts on Web Components and Dart.)In the context of user interfaces, data binding is the technique of keeping both data and the view in sync. If the data changes, update the view. If the view changes, update the data. It's the later scenario (view changing the data) that I discuss in this post.HTML views can update data via input fields. Input fields can be bound to data, both displaying the data and updating the data. Use theattribute on input fields such as text, textarea, and select.The above code sample shows two data bindings. The first,, we saw in my previous post . The second, data-bind, is how you declare a binding for an input field.Specifically,is saying "bind the superlative variable found in Dart code to the value attribute of this input field". The Dart Web Components document calls this "two-way binding", because the input field itself is bound in two ways: reading and writing the variable.In this simple example, the Dart code only declares the variable and defines the main method.One of the main benefits of Web Components is that everything is very declarative, so the need for glue code or explicit event handlers is diminished.Best to show this off live, so you can see the live data binding.Notice how the display is updated as the user types in the input field. To make this happen, almost no code was created, and everything was simply declared in the HTML. Awesome!Use the data-bind attribute on input fields to declare live "two-way" data binding. When the variable's value is changed, the input field changes. When the user updates the input field, the variable's value changes.Read the Dart Web Components documentation or check out my other blog posts on Dart Web Components . The code from this post , and other examples of Dart Web Components, is available on Github Thanks!