Ho una variabile globale dichiarata nell'intestazione html e voglio farvi riferimento da una classe all'interno di un modulo. Come posso evitare l'errore del compilatore:Riferimento alla variabile globale da un modulo
errore TS2095: Impossibile trovare il simbolo 'selfGlobal'.
<html>
<head>
<script>
var selfGlobal = this;
var globalVariable = 1;
</script>
</head>
<body>
<script src="test.js"></script>
</body>
</html>
In test.ts
module Test{
export class TestClass {
private _privateVariable:any;
constructor() {
this._privateVariable = selfGlobal.globalVariable; // compile error throws here, but the code can run
}
}
}
Grazie! Mars
Vedi anche http://stackoverflow.com/questions/13252225/call-a-global-variable-inside-typescript-module – koppor