File

async/directives/safe.directive.ts

Description

Makes sure that the element it is placed on only gets rendered once Google Maps API has fully loaded.

Implements

OnInit

Metadata

Index

Methods

Constructor

constructor(templateRef: TemplateRef, viewContainerRef: ViewContainerRef, api: GoogleMapsApiService)
Parameters:
Name Type Optional
templateRef TemplateRef<any> No
viewContainerRef ViewContainerRef No
api GoogleMapsApiService No

Methods

ngOnInit
ngOnInit()

Waits for maps API to load, then renderes the element.

Returns: void
import { Directive, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';

import { GoogleMapsApiService } from '@bespunky/angular-google-maps/core';

/**
 * Makes sure that the element it is placed on only gets rendered once Google Maps API has fully loaded.
 *
 * @export
 * @class SafeDirective
 * @implements {OnInit}
 */
@Directive({
    selector: '[bsSafe]'
})
export class SafeDirective implements OnInit
{
    constructor(private templateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef, private api: GoogleMapsApiService) { }

    /**
     * Waits for maps API to load, then renderes the element.
     *
     */
    ngOnInit()
    {
        this.api.whenReady.then(() => this.viewContainerRef.createEmbeddedView(this.templateRef));
    }
}

results matching ""

    No results matching ""