### File

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

### Implements

`OnInit`

### Metadata

Selector | `[creParticleBackground]`

### Index

###### Properties
Private elementId
###### Methods
Public ngOnInit
###### Inputs
creParticleBackground

### Constructor

`constructor(elementRef: ElementRef, math: Data)`
Defined in projects/commons/src/lib/elements/particle/directives/background/particle-background.directive.ts:15
Parameters :
Name | Type | Optional
elementRef | `ElementRef` | No
math | `Data` | No

### Inputs

creParticleBackground
Type : `any`
Defined in projects/commons/src/lib/elements/particle/directives/background/particle-background.directive.ts:13

### Methods

Public ngOnInit
`ngOnInit()`
Defined in projects/commons/src/lib/elements/particle/directives/background/particle-background.directive.ts:23
Returns : `void`

### Properties

Private elementId
Type : `string`
Defined in projects/commons/src/lib/elements/particle/directives/background/particle-background.directive.ts:15

    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 ""