Can anyone explain how to add particle js background for angular 6 project? I followed some tutorials as bellow link.but it didn\'t work for me. https://github.com/VincentGarrea
This is how I got it to work in my NG6 project:
In your component ngOnInit add the following code:
particlesJS.load('particles-js', 'assets/data/particles.json', function() { console.log('callback - particles.js config loaded'); });
Hope this helps!
EDIT: Added code
import { Component, OnInit } from '@angular/core';
import { ParticlesConfig } from './../../../../../assets/data/particles';
declare var particlesJS: any;
@Component({
selector: 'app-heading',
templateUrl: './heading.component.html',
styleUrls: ['./heading.component.scss']
})
export class HeadingComponent implements OnInit {
constructor() { }
ngOnInit() {
// https://vincentgarreau.com/particles.js/
particlesJS('particles-js', ParticlesConfig, function() {
console.log('callback - particles.js config loaded');
});
}
}
the template
Big Header
small header
and the use in another component