src/lazy-block.component.ts
changeDetection | ChangeDetectionStrategy.OnPush |
encapsulation | ViewEncapsulation.None |
selector | lazy-block |
styles | lazy-block {display:block} |
template |
|
Properties |
Methods |
constructor(page: LazyPageComponent)
|
||||||
Defined in src/lazy-block.component.ts:16
|
||||||
Parameters :
|
render |
render()
|
Defined in src/lazy-block.component.ts:24
|
Returns :
void
|
isRender |
isRender:
|
Default value : false
|
Defined in src/lazy-block.component.ts:14
|
page |
page:
|
Type : LazyPageComponent
|
Defined in src/lazy-block.component.ts:13
|
tplRef |
tplRef:
|
Type : TemplateRef<any>
|
Decorators : ViewChild
|
Defined in src/lazy-block.component.ts:15
|
tplVcRef |
tplVcRef:
|
Type : ViewContainerRef
|
Decorators : ViewChild
|
Defined in src/lazy-block.component.ts:16
|
import { Component, ViewEncapsulation, ChangeDetectionStrategy, TemplateRef, ViewChild, Host, ViewContainerRef, Inject, forwardRef } from '@angular/core';
import { LazyPageComponent } from './lazy-page.component';
@Component({
selector: 'lazy-block',
styles: ['lazy-block {display:block}'],
template: '<ng-template #tpl><ng-content></ng-content></ng-template>',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
})
export class LazyBlockComponent {
page: LazyPageComponent;
isRender = false;
@ViewChild('tpl') tplRef: TemplateRef<any>;
@ViewChild('tpl', { read: ViewContainerRef }) tplVcRef: ViewContainerRef;
constructor(
@Host()
@Inject(forwardRef(() => LazyPageComponent))
page: LazyPageComponent
) {
this.page = page;
}
render() {
this.tplVcRef.createEmbeddedView(this.tplRef);
this.isRender = true;
requestAnimationFrame(() => {
this.page.render();
});
}
}