Implementierungsleitfaden
Angular-Integration
Integrieren Sie Tagtics mit modernen Lifecycle-Hooks. Der Client übernimmt Routenwechsel automatisch für Sie.
Initialisierung
Rufen Sie init auf, wenn Ihre App gemountet wird, und destroy beim Unmounten, um Speicherlecks zu vermeiden.
import { Component, OnInit, OnDestroy } from '@angular/core';
@Component({...})
export class AppComponent implements OnInit, OnDestroy {
private script?: HTMLScriptElement;
ngOnInit() {
this.script = document.createElement('script');
this.script.src = 'https://cdn.tagtics.online/client.js';
this.script.async = true;
this.script.onload = () => {
(window as any).Tagtics?.init({ apiKey: 'YOUR_API_KEY' });
};
document.body.appendChild(this.script);
}
ngOnDestroy() {
(window as any).Tagtics?.destroy();
this.script?.remove();
}
}