Index: samples/third_party/todomvc/web/app.dart |
diff --git a/samples/third_party/todomvc/web/app.dart b/samples/third_party/todomvc/web/app.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2cbe85c62b3b0be951b48ed8675d81bc8fb13f8 |
--- /dev/null |
+++ b/samples/third_party/todomvc/web/app.dart |
@@ -0,0 +1,30 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library app; |
+ |
+import 'dart:html'; |
+import 'package:polymer/polymer.dart'; |
+import 'model.dart'; |
+ |
+@CustomTag("todo-app") |
+class TodoApp extends PolymerElement with ObservableMixin { |
+ @observable AppModel app; |
+ bool get applyAuthorStyles => true; |
+ |
+ void created() { |
+ super.created(); |
+ app = appModel; |
+ } |
+ |
+ void addTodo(Event e) { |
+ e.preventDefault(); // don't submit the form |
+ var input = getShadowRoot('todo-app').query('#new-todo'); |
+ if (input.value == '') return; |
+ app.todos.add(new Todo(input.value)); |
+ input.value = ''; |
+ } |
+ |
+ void clear() => app.clearDone(); |
+} |