Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: example/todomvc/main.dart

Issue 12225039: Support for observable models, fixes #259 (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: small formatting fixes Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library main; 5 library main;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'model.dart'; 8 import 'model.dart';
9 import 'package:web_ui/web_ui.dart'; 9 import 'package:web_ui/web_ui.dart';
10 10
11 main() { 11 main() {}
12 // listen on changes to #hash in the URL
13 // Note: listen on both popState and hashChange, because IE9 doens't support
14 // history API, and it doesn't work properly on Opera 12.
15 // See http://dartbug.com/5483
16 updateFilters(e) {
17 viewModel.showIncomplete = window.location.hash != '#/completed';
18 viewModel.showDone = window.location.hash != '#/active';
19 dispatch();
20 }
21 window.onHashChange.listen(updateFilters);
22 window.onPopState.listen(updateFilters);
23 }
24 12
25 void addTodo(Event e) { 13 void addTodo(Event e) {
26 e.preventDefault(); // don't submit the form 14 e.preventDefault(); // don't submit the form
27 var input = query('#new-todo'); 15 var input = query('#new-todo');
28 if (input.value == '') return; 16 if (input.value == '') return;
29 app.todos.add(new Todo(input.value)); 17 app.todos.add(new Todo(input.value));
30 input.value = ''; 18 input.value = '';
31 } 19 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698