I recently wrote a JavaScript file that is meant to return values to TypeScript files within my Angular project.
var webGlObject = (function() {
return {
init: function() {
alert('webGlObject initialized');
}
}
})(webGlObject||{})
import { Component, OnInit } from '@angular/core';
import '../../../lib/jquery-3.2.1.min.js';
import '../../../server/getSummary.js';
declare var webGlObject: any;
@Component({
selector: 'mop-designer-dashboard',
templateUrl: 'mop-designer-dashboard.component.html',
styleUrls: ['mop-designer-dashboard.component.css'],
})
export class MopDesignerDashboardComponent implements OnInit {
debugger;
scoreBoardList: any = [];
breadcrumb: any = [];
constructor() {
/* prepare breadcrumb */
this.breadcrumb = [
{
label: 'Mop Designer',
href: '/#/mop-designer'
}
];
debugger;
webGlObject.init();
}
ngOnInit() {
console.log('test');
}
}
However, there seems to be an issue as the declaration of 'webGlObject: any;' does not actually create an object, resulting in the following error:
> ZoneTask.invoke @ zone.js?fad3:339 VM292602:61 Error: Uncaught (in promise): Error: Error in :0:0 caused by: webGlObject is not defined ReferenceError: webGlObject is not defined at new MopDesignerDashboardComponent