2016-10-12 17:58:32 +00:00
|
|
|
import 'dart:html';
|
|
|
|
import 'package:angel_route/browser.dart';
|
|
|
|
|
|
|
|
basic(BrowserRouter router) {
|
|
|
|
final $h1 = window.document.querySelector('h1');
|
|
|
|
final $ul = window.document.getElementById('handlers');
|
|
|
|
|
|
|
|
router.onRoute.listen((route) {
|
|
|
|
if (route == null) {
|
|
|
|
$h1.text = 'No Active Route';
|
|
|
|
$ul.children
|
|
|
|
..clear()
|
|
|
|
..add(new LIElement()..text = '(empty)');
|
|
|
|
} else {
|
|
|
|
$h1.text = 'Active Route: ${route.path}';
|
|
|
|
$ul.children
|
|
|
|
..clear()
|
|
|
|
..addAll(route.handlerSequence
|
|
|
|
.map((handler) => new LIElement()..text = handler.toString()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
router.get('a', 'a handler');
|
|
|
|
|
|
|
|
router.group('b', (router) {
|
2016-10-19 22:04:06 +00:00
|
|
|
print(router.root);
|
2016-10-12 17:58:32 +00:00
|
|
|
router.get('a', 'b/a handler');
|
|
|
|
router.get('b', 'b/b handler', middleware: ['b/b middleware']);
|
|
|
|
}, middleware: ['b middleware']);
|
|
|
|
|
|
|
|
router.get('c', 'c handler');
|
|
|
|
|
|
|
|
router.dumpTree();
|
|
|
|
}
|