Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active September 10, 2020 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/ce20ec125fbe9c74613c5e86dbb2dc2a to your computer and use it in GitHub Desktop.
Save bjoerntx/ce20ec125fbe9c74613c5e86dbb2dc2a to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
declare var TXDocumentViewer: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'my-viewer-app';
onTabChanged($event) {
// the DocumentViewer doesn't exist on tab page
if (document.getElementById("txViewer") === null) {
if (typeof(TXDocumentViewer) !== "undefined") {
TXDocumentViewer = undefined;
}
}
else { // the DocumentViewer exists
// wait until object TXDocumentViewer is available (lazy loading)
var checkExist = setInterval(function() {
if (typeof TXDocumentViewer !== "undefined") {
// call init to initialize the viewer
TXDocumentViewer.init( {
containerID: 'txViewer',
viewerSettings: {
toolbarDocked: true,
documentData: "SGVsbG8gdGhlcmU=",
dock: "Fill",
isSelectionActivated: true,
showThumbnailPane: true,
basePath: 'https://backend.textcontrol.com',
}
});
clearInterval(checkExist);
}
}, 100);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment