Using the original package, without https://github.com/audrenbdb/angular-particlesjs you can do the following:
Install it using npm i particles.js
app.component.html
<div id="particles-js"></div>
app.component.ts
import { Component, OnInit } from '@angular/core'; import { ParticlesConfig } from './particles-config'; declare let particlesJS: any; // Required to be properly interpreted by TypeScript. @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent implements OnInit { public ngOnInit(): void { this.invokeParticles(); } public invokeParticles(): void { particlesJS('particles-js', ParticlesConfig, function() {}); } }
particles-config.ts
export const ParticlesConfig = { particles: { number: { value: 70, density: { enable: true, value_area: 1400 } }, color: { value: '#283593' }, shape: { type: 'polygon', stroke: { width: 1, color: '#283593' }, polygon: { nb_sides: 6 } }, opacity: { value: 1, random: true, anim: { enable: true, speed: 0.8, opacity_min: 0.25, sync: true } }, size: { value: 2, random: true, anim: { enable: true, speed: 10, size_min: 1.25, sync: true } }, line_linked: { enable: true, distance: 150, color: '#283593', opacity: 1, width: 1 }, move: { enable: true, speed: 8, direction: 'none', random: true, straight: false, out_mode: 'out', bounce: true, attract: { enable: true, rotateX: 2000, rotateY: 2000 } } }, interactivity: { detect_on: 'canvas', events: { onhover: { enable: true, mode: 'grab' }, onclick: { enable: true, mode: 'repulse' }, resize: true }, modes: { grab: { distance: 200, line_linked: { opacity: 3 } }, repulse: { distance: 250, duration: 2 } } }, retina_detect: true
};
app.component.scss (optional to display it at full height)
#particles-js { height: 100vh; }
angular.json
"scripts": ["node_modules/particles.js/particles.js"]