This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
return { | |
get() { | |
if (!inited) { | |
inited = true; | |
triger.next(); | |
} | |
return originalDescriptor | |
? originalDescriptor.get.call(compRef.instance) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
triger | |
.pipe( | |
switchMap(() => { | |
const currentActivatedOutlet = getCurrentOutlet( | |
rootContextMap, | |
target.constructor | |
); | |
if (!currentActivatedOutlet) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function NgResolve(name?: string, propagation = true) { | |
return function( | |
target: any, | |
key: string, | |
originalDescriptor?: TypedPropertyDescriptor<any> | |
): any { | |
const router = StaticInjectorService.Injector.get(Router); | |
const triger = new Subject(); | |
const destroyer = new Subject(); | |
const rootContextMap = (router as any).rootContexts.contexts as Map< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChangeDetectorRef, ComponentRef } from '@angular/core'; | |
import { OutletContext, Router } from '@angular/router'; | |
import { Subject } from 'rxjs'; | |
import { pluck, switchMap, takeUntil } from 'rxjs/operators'; | |
import { getCurrentOutlet } from '../functions/get-current-outlet'; | |
import { getRouteWithData } from '../functions/get-route-with-data'; | |
import { StaticInjectorService } from '../services/static-injector.service'; | |
export function NgResolve(name?: string, propagation = true) { | |
return function( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{ | |
path: ':id', | |
component: LazyComponent, | |
resolve: { | |
data: LazyResolverService | |
}, | |
children: [ | |
{ | |
path: 'nested', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{ | |
path: ':id', | |
component: LazyComponent, | |
resolve: { | |
data: LazyResolverService | |
}, | |
children: [ | |
{ | |
path: 'nested', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChangeDetectionStrategy, Component } from '@angular/core'; | |
import { NgResolve } from '../../ng-resolve/decorators/ng-resolve.decorator'; | |
@Component({ | |
selector: 'app-nested', | |
template: ` | |
<div>I'm nested! And NgResolve doesn't work here :(</div> | |
<br /> | |
{{ nestedData }} | |
`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChangeDetectorRef, ComponentRef } from '@angular/core'; | |
import { OutletContext, Router } from '@angular/router'; | |
import { Subject } from 'rxjs'; | |
import { pluck, switchMap, takeUntil } from 'rxjs/operators'; | |
import { getCurrentOutlet } from '../functions/get-current-outlet'; | |
import { getRouteWithData } from '../functions/get-route-with-data'; | |
import { StaticInjectorService } from '../services/static-injector.service'; | |
export function NgResolve(name?: string, propagation = true) { | |
return function( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
return { | |
get() { | |
if (!inited) { | |
inited = true; | |
triger.next(); | |
} | |
return originalDescriptor | |
? originalDescriptor.get.call(target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
.subscribe({ | |
next: data => { | |
target[key] = data; | |
cdr.markForCheck(); | |
} | |
}); | |
... |
NewerOlder