Skip to content

Commit 3791c4a

Browse files
IAParkbtford
authored andcommitted
fix(RouteRegistry): initialize RouteParams.params
Fix a bug caused by RouteRegistry.generate not initializing RouteParams.params to a StringMap Closes angular#3755
1 parent ecf6ba3 commit 3791c4a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

modules/angular2/src/router/route_registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export class RouteRegistry {
211211
} else if (segment == '' || segment == '.' || segment == '..') {
212212
throw new BaseException(`"${segment}/" is only allowed at the beginning of a link DSL.`);
213213
}
214-
let params = null;
214+
let params = {};
215215
if (i + 1 < linkParams.length) {
216216
let nextSegment = linkParams[i + 1];
217217
if (isStringMap(nextSegment)) {

modules/angular2/test/router/route_registry_spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ export function main() {
7979
expect(url).toEqual('first/one/second/two');
8080
});
8181

82+
it('should geneate params as an empty StringMap when no params are given', () => {
83+
registry.config(RootHostCmp,
84+
new Route({path: '/test/...', component: DummyParentParamCmp, as: 'test'}));
85+
var instruction = registry.generate(['test'], RootHostCmp);
86+
expect(instruction.component.params).toEqual({});
87+
});
88+
8289
it('should generate URLs of loaded components after they are loaded',
8390
inject([AsyncTestCompleter], (async) => {
8491
registry.config(

0 commit comments

Comments
 (0)