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

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

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback Created 6 years, 9 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
1 part of angular.routing; 1 part of angular.routing;
2 2
3 /** 3 /**
4 * A directive that allows to bind child components/directives to a specific 4 * A directive that allows to bind child components/directives to a specific
5 * route. 5 * route.
6 * 6 *
7 * <div ng-bind-route="foo.bar"> 7 * <div ng-bind-route="foo.bar">
8 * <my-component></my-component> 8 * <my-component></my-component>
9 * </div> 9 * </div>
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 * 21 *
22 * ng-bind-route overrides [RouteProvider] instance published by ng-view, 22 * ng-bind-route overrides [RouteProvider] instance published by ng-view,
23 * however it does not effect view resolution by nested ng-view(s). 23 * however it does not effect view resolution by nested ng-view(s).
24 */ 24 */
25 @NgDirective( 25 @NgDirective(
26 visibility: NgDirective.CHILDREN_VISIBILITY, 26 visibility: NgDirective.CHILDREN_VISIBILITY,
27 publishTypes: const [RouteProvider], 27 publishTypes: const [RouteProvider],
28 selector: '[ng-bind-route]', 28 selector: '[ng-bind-route]',
29 map: const { 29 map: const {
30 'ng-bind-route': '@routeName' 30 'ng-bind-route': '@routeName'
31 } 31 })
32 )
33 class NgBindRouteDirective implements RouteProvider { 32 class NgBindRouteDirective implements RouteProvider {
34 Router _router; 33 Router _router;
35 String routeName; 34 String routeName;
36 Injector _injector; 35 Injector _injector;
37 36
38 // We inject NgRoutingHelper to force initialization of routing. 37 // We inject NgRoutingHelper to force initialization of routing.
39 NgBindRouteDirective(this._router, this._injector, NgRoutingHelper _); 38 NgBindRouteDirective(this._router, this._injector, NgRoutingHelper _);
40 39
41 /// Returns the parent [RouteProvider]. 40 /// Returns the parent [RouteProvider].
42 RouteProvider get _parent => _injector.parent.get(RouteProvider); 41 RouteProvider get _parent => _injector.parent.get(RouteProvider);
43 42
44 Route get route { 43 Route get route => routeName.startsWith('.') ?
45 if (routeName.startsWith('.')) { 44 _parent.route.getRoute(routeName.substring(1)) :
46 return _parent.route.getRoute(routeName.substring(1)); 45 _router.root.getRoute(routeName);
47 } else {
48 return _router.root.getRoute(routeName);
49 }
50 }
51 46
52 Map<String, String> get parameters { 47 Map<String, String> get parameters {
53 var res = <String, String>{}; 48 var res = <String, String>{};
54 var p = route; 49 var p = route;
55 while (p != null) { 50 while (p != null) {
56 res.addAll(p.parameters); 51 res.addAll(p.parameters);
57 p = p.parent; 52 p = p.parent;
58 } 53 }
59 return res; 54 return res;
60 } 55 }
61 } 56 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/routing/module.dart ('k') | third_party/pkg/angular/lib/routing/ng_view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698