Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NativeScript/nativescript-angular
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.1
Choose a base ref
...
head repository: NativeScript/nativescript-angular
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.2
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 18, 2017

  1. fix: use providers' map for injectors in page-router-outlet (#744) (#748

    )
    
    Instantiate child injectors with a providers' map for outlet specific
    providers such as Page, PageRoute, ActivatedRoute, etc.
    
    fixes #741
    sis0k0 authored Apr 18, 2017
    Copy the full SHA
    c1f5d98 View commit details
  2. release: cut the 1.5.2 release (#758)

    * release: cut the 1.5.2 release
    
    * docs: update CHANGELOG for 1.5.2
    sis0k0 authored and Vasil Chimev committed Apr 18, 2017
    Copy the full SHA
    a3e8fe9 View commit details
Showing with 30 additions and 41 deletions.
  1. +10 −0 CHANGELOG.md
  2. +2 −2 nativescript-angular/package.json
  3. +18 −39 nativescript-angular/router/page-router-outlet.ts
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="1.5.2"></a>
## [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)



<a name="1.5.1"></a>
## [1.5.1](https://github.com/NativeScript/nativescript-angular/compare/v1.5.0...v1.5.1) (2017-03-30)

4 changes: 2 additions & 2 deletions nativescript-angular/package.json
Original file line number Diff line number Diff line change
@@ -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": [
57 changes: 18 additions & 39 deletions nativescript-angular/router/page-router-outlet.ts
Original file line number Diff line number Diff line change
@@ -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<Type<any>|InjectionToken<any>, 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<any> {
const snapshot = activatedRoute._futureSnapshot;
const component = <any>snapshot._routeConfig.component;
let factory: ComponentFactory<any>;

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<Type<any>|InjectionToken<any>, any>,
private parent: Injector
) {}

return super.get(token, notFoundValue);
get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T {
return this.providers.get(token) || this.parent.get(token, notFoundValue);
}
}