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

Unified Diff: samples/third_party/angular_todo/web/todo.dart

Issue 1058283006: Update pubspecs and dependencies to get pkgbuild tests working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | « samples/third_party/angular_todo/web/index.html ('k') | third_party/pkg/angular/.agignore » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/third_party/angular_todo/web/todo.dart
diff --git a/samples/third_party/angular_todo/web/todo.dart b/samples/third_party/angular_todo/web/todo.dart
deleted file mode 100644
index f82b5dc773d70e0c37684943c43479e6aa97aff1..0000000000000000000000000000000000000000
--- a/samples/third_party/angular_todo/web/todo.dart
+++ /dev/null
@@ -1,124 +0,0 @@
-library todo;
-
-import 'dart:html';
-
-import 'package:angular/angular.dart';
-import 'package:angular/application_factory.dart';
-import 'package:angular/playback/playback_http.dart';
-
-class Item {
- String text;
- bool done;
-
- Item([this.text = '', this.done = false]);
-
- bool get isEmpty => text.isEmpty;
-
- Item clone() => new Item(text, done);
-
- void clear() {
- text = '';
- done = false;
- }
-}
-
-
-// ServerController interface. Logic in main.dart determines which
-// implementation we should use.
-abstract class Server {
- init(Todo todo);
-}
-
-
-// An implementation of ServerController that does nothing.
-@Injectable()
-class NoOpServer implements Server {
- init(Todo todo) { }
-}
-
-
-// An implementation of ServerController that fetches items from
-// the server over HTTP.
-@Injectable()
-class HttpServer implements Server {
- final Http _http;
- HttpServer(this._http);
-
- init(Todo todo) {
- _http(method: 'GET', url: '/todos').then((HttpResponse data) {
- data.data.forEach((d) {
- todo.items.add(new Item(d["text"], d["done"]));
- });
- });
- }
-}
-
-
-@Controller(
- selector: '[todo-controller]',
- publishAs: 'todo')
-class Todo {
- var items = <Item>[];
- Item newItem;
-
- Todo(Server serverController) {
- newItem = new Item();
- items = [
- new Item('Write Angular in Dart', true),
- new Item('Write Dart in Angular'),
- new Item('Do something useful')
- ];
-
- serverController.init(this);
- }
-
- void add() {
- if (newItem.isEmpty) return;
-
- items.add(newItem.clone());
- newItem.clear();
- }
-
- void markAllDone() {
- items.forEach((item) => item.done = true);
- }
-
- void archiveDone() {
- items.removeWhere((item) => item.done);
- }
-
- String classFor(Item item) => item.done ? 'done' : '';
-
- int remaining() => items.fold(0, (count, item) => count += item.done ? 0 : 1);
-}
-
-
-main() {
- print(window.location.search);
- var module = new Module()
- ..bind(Todo)
- ..bind(PlaybackHttpBackendConfig);
-
- // If these is a query in the URL, use the server-backed
- // controller. Otherwise, use the stored-data controller.
- var query = window.location.search;
- if (query.contains('?')) {
- module.bind(Server, toImplementation: HttpServer);
- } else {
- module.bind(Server, toImplementation: NoOpServer);
- }
-
- if (query == '?record') {
- print('Using recording HttpBackend');
- var wrapper = new HttpBackendWrapper(new HttpBackend());
- module.bind(HttpBackendWrapper, toValue: new HttpBackendWrapper(new HttpBackend()));
- module.bind(HttpBackend, toImplementation: RecordingHttpBackend);
- }
-
- if (query == '?playback') {
- print('Using playback HttpBackend');
- module.bind(HttpBackend, toImplementation: PlaybackHttpBackend);
- }
-
- applicationFactory().addModule(module).run();
-}
« no previous file with comments | « samples/third_party/angular_todo/web/index.html ('k') | third_party/pkg/angular/.agignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698