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

Unified Diff: example/angular/routing/accessing_router_in_controller/my_controller.dart

Issue 135183008: First group of routing examples (Closed) Base URL: https://github.com/dart-lang/dart_by_example.git@master
Patch Set: Created 6 years, 11 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
Index: example/angular/routing/accessing_router_in_controller/my_controller.dart
diff --git a/example/angular/routing/accessing_router_in_controller/my_controller.dart b/example/angular/routing/accessing_router_in_controller/my_controller.dart
new file mode 100644
index 0000000000000000000000000000000000000000..01e7d799c7bb897f560c015bc0ad554aa922c213
--- /dev/null
+++ b/example/angular/routing/accessing_router_in_controller/my_controller.dart
@@ -0,0 +1,35 @@
+// 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 my_controller;
+
+import 'package:angular/angular.dart';
+import './book.dart' show Book;
+
+@NgController(
+ selector: '[my-controller]',
+ publishAs: 'ctrl'
+)
+class MyController implements NgDetachAware {
+ RouteHandle route;
+ Book book;
+ Map<String, Book> bookMap = {
+ "1": new Book('War and Peace', 'A really long book'),
+ "2": new Book('The Old Man and the Sea', 'A really short book')
+ };
+
+ MyController(RouteProvider router) {
+ route = router.route.newHandle();
+
+ route.onRoute.listen((RouteEvent e) {
+ print(route.runtimeType);
pavelj 2014/01/21 21:59:59 remove
+ var _bookId = route.parameters['bookId'];
+ book = bookMap[_bookId];
+ });
+ }
+
+ detach() {
+ route.discard();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698