Greetings, I am in the process of upgrading an existing Angular application from version 2 to 9. My approach involves first moving it to angular 4 and then continuing with the upgrades. I have successfully updated the necessary packages, but now I'm encountering an error stating that a variable is not defined. Here is the current app structure:
I have a file named legend.component.js
var LegendSingleton = function() {
...
createInstance
...
getInstance
...
Next, there is main.component.js
var myExtObject = {
...
legend: LegendSingleton.getInstance()
...
Now, in layoutindicateur.component.ts
...
var myExtObject = require('../../../assets/geoFunction/main.component.js');
some use of myExtObject
...
Furthermore, in angular-cli.json
, I have declared these JS files within the scripts
:
...
"assets/geoFunction/component/legend.component.js",
...
"assets/geoFunction/main.component.js"
The error I am facing is
Uncaught (in promise): ReferenceError: LegendSingleton is not defined
. I attempted to import the legend JS file into the main JS file using var LegendSingleton = require('../geoFunction/component/legend.component.js');
. However, this resulted in an error stating that getInstance
is not a function.