2

I am trying to import openseadragon.min.js file in index.html and using it's function like below,

var viewer = OpenSeadragon({
  id: "seadragon-viewer"
});

But it is throwing error like OpenSeadragon is undefined.

Any solutions will be appreciated, Thank you

Sai M.
  • 2,548
  • 4
  • 29
  • 46
Siva Kumar S
  • 409
  • 1
  • 6
  • 21

2 Answers2

2

Try declaring the variable at the top of your component immediately below your imports, not inside your class export statement.

import { Component } from '@angular/core';

declare var OpenSeadragon: any;

@Component({
...
})
Stephen R. Smith
  • 3,310
  • 1
  • 25
  • 41
0

You need angular typings to do this correctly for OpenSeadragon. You also shouldn't be using vars in typescript as it breaks context and causes scope and hoisting issues.

Please see https://github.com/alvaromartmart/types-openseadragon for typings