diff --git a/CHANGELOG.md b/CHANGELOG.md
index 254dfef98..2fa0bdb70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+
+## [1.5.2](https://github.com/NativeScript/nativescript-angular/compare/v1.5.1...v1.5.2) (2017-04-18)
+
+
+### Bug Fixes
+
+* use providers' map for injectors in page-router-outlet ([#744](https://github.com/NativeScript/nativescript-angular/issues/744)) ([#748](https://github.com/NativeScript/nativescript-angular/issues/748)) ([c1f5d98](https://github.com/NativeScript/nativescript-angular/commit/c1f5d98)), closes [#741](https://github.com/NativeScript/nativescript-angular/issues/741)
+
+
+
## [1.5.1](https://github.com/NativeScript/nativescript-angular/compare/v1.5.0...v1.5.1) (2017-03-30)
diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json
index e50321de6..eb80e8a23 100644
--- a/nativescript-angular/package.json
+++ b/nativescript-angular/package.json
@@ -1,8 +1,8 @@
{
"private": true,
"name": "nativescript-angular",
- "version": "1.5.1",
- "description": "An Angular 2 renderer that lets you build mobile apps with NativeScript.",
+ "version": "1.5.2",
+ "description": "An Angular renderer that lets you build mobile apps with NativeScript.",
"homepage": "http://www.telerik.com",
"bugs": "http://www.telerik.com",
"contributors": [
diff --git a/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts
index c6f730499..7c044f619 100644
--- a/nativescript-angular/router/page-router-outlet.ts
+++ b/nativescript-angular/router/page-router-outlet.ts
@@ -1,6 +1,6 @@
import {
Attribute, ComponentFactory, ComponentRef, Directive,
- ViewContainerRef,
+ ViewContainerRef, Type, InjectionToken,
Inject, ComponentFactoryResolver, Injector
} from "@angular/core";
import { RouterOutletMap, ActivatedRoute, PRIMARY_OUTLET } from "@angular/router";
@@ -167,19 +167,22 @@ export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
activatedRoute: ActivatedRoute,
outletMap: RouterOutletMap,
loadedResolver: ComponentFactoryResolver): void {
- const factory = this.getComponentFactory(activatedRoute, loadedResolver);
-
const pageRoute = new PageRoute(activatedRoute);
+ let providers = new Map|InjectionToken, any>();
+ providers.set(PageRoute, pageRoute);
+ providers.set(ActivatedRoute, activatedRoute);
+ providers.set(RouterOutletMap, outletMap);
+ const childInjector = new ChildInjector(providers, this.location.injector);
+
+ const factory = this.getComponentFactory(activatedRoute, loadedResolver);
if (this.isInitialPage) {
log("PageRouterOutlet.activate() initial page - just load component");
this.isInitialPage = false;
- const injector = new OutletInjector(activatedRoute, outletMap, this.location.injector);
this.currentActivatedComp = this.location.createComponent(
- factory, this.location.length, injector, []);
-
+ factory, this.location.length, childInjector, []);
this.currentActivatedComp.changeDetectorRef.detectChanges();
this.refCache.push(this.currentActivatedComp, pageRoute, outletMap, null);
@@ -193,7 +196,7 @@ export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
componentType: factory.componentType
});
- const childInjector = new ChildInjector(activatedRoute, outletMap, page, this.location.injector);
+ providers.set(Page, page);
const loaderRef = this.location.createComponent(
this.detachedLoaderFactory, this.location.length, childInjector, []);
@@ -264,47 +267,23 @@ export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
): ComponentFactory {
const snapshot = activatedRoute._futureSnapshot;
const component = snapshot._routeConfig.component;
- let factory: ComponentFactory;
if (loadedResolver) {
- factory = loadedResolver.resolveComponentFactory(component);
+ return loadedResolver.resolveComponentFactory(component);
} else {
- factory = this.componentFactoryResolver.resolveComponentFactory(component);
- }
-
- return factory;
- }
-}
-
-class OutletInjector implements Injector {
- constructor(
- private route: ActivatedRoute, private map: RouterOutletMap, private parent: Injector) { }
-
- get(token: any, notFoundValue?: any): any {
- if (token === ActivatedRoute) {
- return this.route;
- }
-
- if (token === RouterOutletMap) {
- return this.map;
+ return this.componentFactoryResolver.resolveComponentFactory(component);
}
-
- return this.parent.get(token, notFoundValue);
}
}
-class ChildInjector extends OutletInjector {
+class ChildInjector implements Injector {
constructor(
- route: ActivatedRoute, map: RouterOutletMap, private page: Page, parent: Injector) {
- super(route, map, parent);
- }
-
- get(token: any, notFoundValue?: any): any {
- if (token === Page) {
- return this.page;
- }
+ private providers: Map|InjectionToken, any>,
+ private parent: Injector
+ ) {}
- return super.get(token, notFoundValue);
+ get(token: Type|InjectionToken, notFoundValue?: T): T {
+ return this.providers.get(token) || this.parent.get(token, notFoundValue);
}
}