Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda