File

projects/commons/src/lib/elements/particle/directives/background/particle-background.directive.ts

Implements

OnInit

Metadata

Selector [creParticleBackground]

Index

Properties
Methods
Inputs

Constructor

constructor(elementRef: ElementRef, math: Data)
Parameters :
Name Type Optional
elementRef ElementRef No
math Data No

Inputs

creParticleBackground
Type : any

Methods

Public ngOnInit
ngOnInit()
Returns : void

Properties

Private elementId
Type : string
import { Data } from '@angular/router';
import { Directive, ElementRef, Inject, Input, OnInit } from '@angular/core';

import { PARTICLE_BACKGROUND } from '../../constants';

declare const particlesJS: any;

@Directive({
    selector: '[creParticleBackground]',
})

export class ParticleBackgroundDirective implements OnInit {
    @Input('creParticleBackground') public readonly config: any;

    private elementId: string;

    constructor(
        private readonly elementRef: ElementRef,
        @Inject('Math') private readonly math: Data,
    ) {
    }

    public ngOnInit(): void {
        this.elementId = `cre${ this.math.random() }`;
        this.elementRef.nativeElement.setAttribute('id', this.elementId);

        particlesJS(this.elementId, PARTICLE_BACKGROUND);
    }
}

result-matching ""

    No results matching ""