Skip to content

Instantly share code, notes, and snippets.

@eppleton
Forked from eppleton/Todo.java
Last active October 6, 2015 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eppleton/609b010d36f431ba1aaf to your computer and use it in GitHub Desktop.
Save eppleton/609b010d36f431ba1aaf to your computer and use it in GitHub Desktop.
Knockout API Tutorial - Sample 3
<html>
<head>
<title>PersonView</title>
</head>
<body>
<ol data-bind="foreach: persons">
<li><span data-bind="text: name"></span> is
<span data-bind="text: age"></span> years old.
</li>
</ol>
</body>
</html>
package com.dukescript.tutorial;
import net.java.html.json.Model;
import net.java.html.json.Property;
@Model(className = "PersonList", properties = {
@Property(name = "persons", type = Person.class, array = true)})
public class ViewModel {
@Model(className = "Person", properties = {
@Property(name = "name", type = String.class),
@Property(name = "age", type = int.class)})
public static class PersonModel {}
static {
ViewModel.onPageLoad();
}
public static void onPageLoad() {
PersonList personList = new PersonList(new Person("Bob", 123));
personList.getPersons().add(new Person("Bill", 132));
personList.getPersons().add(new Person("Peter", 111));
personList.applyBindings();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment