0

In my assets folder, I have a script called 'imageTools.js'. In one of my angular type script files I want to call 'imageTools' but it's unrecognised. What's the best way to do this?

As expected here's the error:

[ts] Cannot find name 'ImageTools'.

Here's my code.

detectFiles(event) {
 this.selectedFiles = event.target.files;
  ImageTools.resize(this.selectedFiles[0], {
    width: 1000, 
    height: 1000 
  }, function (blob, didItResize) {
    this.testingBaseSixtyFour(blob);
  });    
}
2

1 Answer 1

0

import your jquery and javascript file in index.html. In your javascript file expose a variable through which you can call your functions.

Initialize that variable in your component and use it in your component it will work for you.

 var detect =  function(){
    detectFiles =function detectFiles(event) {
     this.selectedFiles = event.target.files;
      ImageTools.resize(this.selectedFiles[0], {
        width: 1000, 
        height: 1000 
      }, function (blob, didItResize) {
        this.testingBaseSixtyFour(blob);
      });    
    }
     return detectFiles :detectFiles 
    }

Initiallize detect this variable in your component with return type is any

// detect. detectFiles (event)

like this

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.