Last active
September 10, 2020 10:11
-
-
Save bjoerntx/ce20ec125fbe9c74613c5e86dbb2dc2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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