From 1991bbb2537ee87d6e3f63c5432a6a1acc00ba3a Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Sun, 31 Jan 2016 14:52:19 -0600 Subject: [PATCH] fix(router): Added route data to normalized async route --- .../test/integration/router_spec.js | 25 +++++++++++++++++-- .../src/router/route_config_nomalizer.ts | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/angular1_router/test/integration/router_spec.js b/modules/angular1_router/test/integration/router_spec.js index bea802f366b6..00a2385fc4e8 100644 --- a/modules/angular1_router/test/integration/router_spec.js +++ b/modules/angular1_router/test/integration/router_spec.js @@ -44,7 +44,6 @@ describe('router', function () { expect(elt.text()).toBe('Home'); })); - it('should bind the component to the current router', inject(function($location) { var router; registerComponent('homeCmp', { @@ -74,6 +73,28 @@ describe('router', function () { expect(router).toBeDefined(); })); + it('should work when an async route is provided route data', inject(function($location, $q) { + registerDirective('homeCmp', { + template: 'Home ({{homeCmp.isAdmin}})', + $routerOnActivate: function(next, prev) { + this.isAdmin = next.routeData.data.isAdmin; + } + }); + + registerDirective('app', { + template: '
', + $routeConfig: [ + { path: '/', loader: function() { return $q.when('homeCmp'); }, data: { isAdmin: true } } + ] + }); + + compile(''); + + $location.path('/'); + $rootScope.$digest(); + expect(elt.text()).toBe('Home (true)'); + })); + function registerDirective(name, options) { function factory() { return { @@ -124,4 +145,4 @@ describe('router', function () { } }); } -}); \ No newline at end of file +}); diff --git a/modules/angular2/src/router/route_config_nomalizer.ts b/modules/angular2/src/router/route_config_nomalizer.ts index 16518fa79f5d..cd666e6b3549 100644 --- a/modules/angular2/src/router/route_config_nomalizer.ts +++ b/modules/angular2/src/router/route_config_nomalizer.ts @@ -44,6 +44,7 @@ export function normalizeRouteConfig(config: RouteDefinition, path: config.path, loader: wrappedLoader, name: config.name, + data: config.data, useAsDefault: config.useAsDefault }); } @@ -66,6 +67,7 @@ export function normalizeRouteConfig(config: RouteDefinition, path: config.path, loader: componentDefinitionObject.loader, name: config.name, + data: config.data, useAsDefault: config.useAsDefault }); } else {