Angular applications are typically written in TypeScript. Below is a simple example of Angular 8 component that creates a button. Note that in your TypeScript component you need to declare a variable with exact name 'LiveAgent' (mind the capital L) to be able to use a global variable defined in track.js with the same name.
contact.component.html... <div id="chatButton"></div> ...contact.component.ts
import { Component, OnInit } from '@angular/core';
declare var LiveAgent: any;
@Component({
selector: 'app-contact',
templateUrl: './contact.component.html',
styleUrls: ['./contact.component.css']
})
export class ContactComponent implements OnInit {
constructor() { }
ngOnInit() {
let scriptUrl = 'https://<youraccount>.ladesk.com/scripts/track.js';
let node = document.createElement('script');
node.src = scriptUrl;
node.id = 'la_x2s6df8d';
node.type = 'text/javascript';
node.async = true;
node.charset = 'utf-8';
node.onload = function(e) {
LiveAgent.createButton('BUTTON_ID', document.getElementById("chatButton"));
};
document.getElementsByTagName('head')[0].appendChild(node);
}
}
Replace <youraccount>