Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!