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

Side by Side Diff: third_party/pkg/angular/lib/routing/ng_bind_route.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular.routing;
2
3 /**
4 * A directive that allows to bind child components/directives to a specific
5 * route.
6 *
7 * <div ng-bind-route="foo.bar">
8 * <my-component></my-component>
9 * </div>
10 *
11 * ng-bind-route directives can be nested.
12 *
13 * <div ng-bind-route="foo">
14 * <div ng-bind-route=".bar">
15 * <my-component></my-component>
16 * </div>
17 * </div>
18 *
19 * The '.' prefix indicates that bar route is relative to the route in the
20 * parent ng-bind-route or ng-view directive.
21 *
22 * ng-bind-route overrides [RouteProvider] instance published by ng-view,
23 * however it does not effect view resolution by nested ng-view(s).
24 */
25 @NgDirective(
26 visibility: NgDirective.CHILDREN_VISIBILITY,
27 publishTypes: const [RouteProvider],
28 selector: '[ng-bind-route]',
29 map: const {
30 'ng-bind-route': '@routeName'
31 }
32 )
33 class NgBindRouteDirective implements RouteProvider {
34 Router _router;
35 String routeName;
36 Injector _injector;
37
38 // We inject NgRoutingHelper to force initialization of routing.
39 NgBindRouteDirective(this._router, this._injector, NgRoutingHelper _);
40
41 /// Returns the parent [RouteProvider].
42 RouteProvider get _parent => _injector.parent.get(RouteProvider);
43
44 Route get route {
45 if (routeName.startsWith('.')) {
46 return _parent.route.getRoute(routeName.substring(1));
47 } else {
48 return _router.root.getRoute(routeName);
49 }
50 }
51
52 Map<String, String> get parameters {
53 var res = <String, String>{};
54 var p = route;
55 while (p != null) {
56 res.addAll(p.parameters);
57 p = p.parent;
58 }
59 return res;
60 }
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698