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

Unified Diff: third_party/pkg/angular/demo/todo/web/todo.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pkg/angular/demo/todo/web/main.dart ('k') | third_party/pkg/angular/karma-perf.conf.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/angular/demo/todo/web/todo.dart
===================================================================
--- third_party/pkg/angular/demo/todo/web/todo.dart (revision 33054)
+++ third_party/pkg/angular/demo/todo/web/todo.dart (working copy)
@@ -7,38 +7,24 @@
String text;
bool done;
- Item([this.text = '', this.done = false]);
+ Item([String this.text = '', bool this.done = false]);
bool get isEmpty => text.isEmpty;
- Item clone() => new Item(text, done);
+ clone() => new Item(text, done);
- void clear() {
+ clear() {
text = '';
done = false;
}
}
+// In 'server mode', this class fetches items from the server.
+class ServerController {
+ Http _http;
-// ServerController interface. Logic in main.dart determines which
-// implementation we should use.
-abstract class ServerController {
- init(TodoController todo);
-}
+ ServerController(Http this._http);
-
-// An implementation of ServerController that does nothing.
-class NoServerController implements ServerController {
- init(TodoController todo) { }
-}
-
-
-// An implementation of ServerController that fetches items from
-// the server over HTTP.
-class HttpServerController implements ServerController {
- final Http _http;
- HttpServerController(this._http);
-
init(TodoController todo) {
_http(method: 'GET', url: '/todos').then((HttpResponse data) {
data.data.forEach((d) {
@@ -48,12 +34,20 @@
}
}
+// An implementation of ServerController that does nothing.
+// Logic in main.dart determines which implementation we should
+// use.
+class NoServerController implements ServerController {
+ init(TodoController todo) { }
+}
-@NgController(
- selector: '[todo-controller]',
- publishAs: 'todo')
+
+@NgDirective(
+ selector: '[todo-controller]',
+ publishAs: 'todo'
+)
class TodoController {
- var items = <Item>[];
+ List<Item> items;
Item newItem;
TodoController(ServerController serverController) {
@@ -68,24 +62,33 @@
}
// workaround for https://github.com/angular/angular.dart/issues/37
- dynamic operator [](String key) => key == 'newItem' ? newItem : null;
+ dynamic operator [](String key) {
+ if (key == 'newItem') {
+ return newItem;
+ }
+ return null;
+ }
- void add() {
+ add() {
if (newItem.isEmpty) return;
items.add(newItem.clone());
newItem.clear();
}
- void markAllDone() {
+ markAllDone() {
items.forEach((item) => item.done = true);
}
- void archiveDone() {
+ archiveDone() {
items.removeWhere((item) => item.done);
}
- String classFor(Item item) => item.done ? 'done' : '';
+ String classFor(Item item) {
+ return item.done ? 'done' : '';
+ }
- int remaining() => items.fold(0, (count, item) => count += item.done ? 0 : 1);
+ int remaining() {
+ return items.where((item) => !item.done).length;
+ }
}
« no previous file with comments | « third_party/pkg/angular/demo/todo/web/main.dart ('k') | third_party/pkg/angular/karma-perf.conf.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698