fix(router): handle router outlets in ngIf

This commit is contained in:
vsavkin
2016-06-30 18:24:43 -07:00
parent f65ebec3ed
commit 0c65d5cf2b
5 changed files with 64 additions and 16 deletions

View File

@ -83,9 +83,12 @@ export class RouterLink {
return true;
}
this.router.navigate(
this.urlTree = this.router.createUrlTreeUsingFutureUrl(
this.commands,
{relativeTo: this.route, queryParams: this.queryParams, fragment: this.fragment});
this.router.navigateByUrl(this.urlTree);
return false;
}
}
@ -147,9 +150,10 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
}
private updateTargetUrlAndHref(): void {
this.urlTree = this.router.createUrlTree(
this.urlTree = this.router.createUrlTreeUsingFutureUrl(
this.commands,
{relativeTo: this.route, queryParams: this.queryParams, fragment: this.fragment});
if (this.urlTree) {
this.href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree));
}

View File

@ -71,7 +71,7 @@ export class RouterOutlet {
} catch (e) {
if (!(e instanceof NoComponentFactoryError)) throw e;
// TODO: vsavkin uncomment this once CompoentResolver is deprecated
// TODO: vsavkin uncomment this once ComponentResolver is deprecated
// const componentName = component ? component.name : null;
// console.warn(
// `'${componentName}' not found in precompile array. To ensure all components referred
@ -84,5 +84,6 @@ export class RouterOutlet {
const inj = ReflectiveInjector.fromResolvedProviders(providers, this.location.parentInjector);
this.activated = this.location.createComponent(factory, this.location.length, inj, []);
this.activated.changeDetectorRef.detectChanges();
}
}