Angular embed ReplyBox into a component

I would like to know the correct way of embedding script into angular component.
enter image description here

so right now it’s showing the UI but there are couple of problems

  1. The comments were not loaded.
  2. When I navigate to other route and return to this route.- the entire UI disappears.

This are my effort so far:



  <script src=""></script>

I added the script to the index.html


      <div id="replybox"></div>


import { Component, AfterViewInit, ViewChild, Renderer2, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';

  selector: 'app-replybox',
  templateUrl: './replybox.component.html',
  styleUrls: ['./replybox.component.scss'],
export class ReplyboxComponent implements AfterViewInit {
  @ViewChild('replybox') replybox: any;

    private _renderer2 : Renderer2,
    @Inject(DOCUMENT) private _document: Document
  ) {}

  ngAfterViewInit() {
    let script = this._renderer2.createElement('script');
    script.text = `
    window.replybox = {
      site: 'MY_SITE'

    this._renderer2.appendChild(this._document.body, script);

anyone know how to make this work?

Source: New feed
Source Url Angular embed ReplyBox into a component