File

src/lazy-block.component.ts

Metadata

changeDetection ChangeDetectionStrategy.OnPush
encapsulation ViewEncapsulation.None
selector lazy-block
styles lazy-block {display:block}
template
<ng-template #tpl><ng-content></ng-content></ng-template>

Index

Properties
Methods

Constructor

constructor(page: LazyPageComponent)
Parameters :
Name Type Optional
page LazyPageComponent no

Methods

render
render()
Returns : void

Properties

isRender
isRender:
Default value : false
page
page: LazyPageComponent
Type : LazyPageComponent
tplRef
tplRef: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ViewChild
tplVcRef
tplVcRef: ViewContainerRef
Type : ViewContainerRef
Decorators : ViewChild
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();
        });
    }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""