Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Call a "special" JS function in Angular?

I want to call a JS function which is declared in this manner:

Extract of JS File

    var SOMETHING;
    void 0 === SOMETHING && (SOMETHING = {}), SOMETHING.init = function(config) {
        SOMETHING.version = "1.1.0", console.log("SOMETHING.version: " + SOMETHING.version);
    }

To run this, in TS file I use this way

    let script = this._renderer2.createElement('script');
    script.type = `text/javascript`;
    script.text = `
    var urlThing = '${urlThing }';
    var exito = function (data) {
      alert(JSON.stringify(data));
    };
    var error = function (data) {
      alert(JSON.stringify(data));
    };        
    SOMETHING.init(); //----> the function that I want to call on TS

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

I want to run this in TS directly instead use a script. I tried this way:

Angular.json

"scripts": ["src/assets/klap/KlapSandBox.js"]

TS File that I want to run the function

    import { Component, OnInit } from '@angular/core';
    import { ActivatedRoute } from '@angular/router';

    import { KlapService } from '../../services/klap.service';

    declare function SOMETHING.init();

This throws an error that .init is not found (Cannot find name 'init') and I can't find a solution about that.

Any Suggestions?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda