fix(router): Added route data to normalized async route

Closes #6802
This commit is contained in:
Brandon Roberts 2016-01-31 14:52:19 -06:00 committed by Brandon
parent 0f10624b08
commit df7885c9f5
2 changed files with 25 additions and 2 deletions

View File

@ -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: '<div ng-outlet></div>',
$routeConfig: [
{ path: '/', loader: function() { return $q.when('homeCmp'); }, data: { isAdmin: true } }
]
});
compile('<app></app>');
$location.path('/');
$rootScope.$digest();
expect(elt.text()).toBe('Home (true)');
}));
function registerDirective(name, options) {
function factory() {
return {
@ -124,4 +145,4 @@ describe('router', function () {
}
});
}
});
});

View File

@ -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 {