O'Reilly logo

Getting Started with Knockout.js for .NET Developers by Andrey Akinshin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Control flow bindings

The control flow bindings are a special kind of bindings that affect a group of elements or other bindings instead of a single element. Also, control flow bindings support alternative syntaxes with comments such as the following (for example, changing parts marked with []):

<!-- ko [binding-name]: [binding-value] -->
  [markup]
<!-- /ko -->

Let's learn about these kinds of bindings through examples.

The foreach binding

The foreach binding allows you to write a single markup that applies to each element in a collection of objects. It is very useful way to render lists and tables. Let's consider the following example (PersonalPage-Binding-Foreach1.html):

The Model will be as follows:

var person = { children: [ { firstName: "Jonnie", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required