OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library my_controller; |
| 6 |
| 7 import 'package:angular/angular.dart'; |
| 8 import 'book.dart' show Book; |
| 9 |
| 10 @NgController( |
| 11 selector: '[my-controller]', |
| 12 publishAs: 'ctrl' |
| 13 ) |
| 14 class MyController implements NgDetachAware { |
| 15 RouteHandle route; |
| 16 String bookId; |
| 17 |
| 18 Map<String, Book> bookMap = { |
| 19 "1": new Book('War and Peace', 'A really long book'), |
| 20 "2": new Book('The Old Man and the Sea', 'A really short book') |
| 21 }; |
| 22 |
| 23 MyController(RouteProvider router) { |
| 24 bookId = router.parameters['bookId']; |
| 25 route = router.route.newHandle(); |
| 26 } |
| 27 |
| 28 detach() { |
| 29 route.discard(); |
| 30 } |
| 31 } |
OLD | NEW |