aurelia - TypeScript How to access object defined in other class -
i have project uses aurelia framework. want make global\static object should accessed across couple files. when try access different file says object undefined. here looks like:
firstfile.ts
export function showa() { console.log("changed " + a); } export var = 3; export class firstfile { public modifya() { = 7; showa(); }
it says = 7. use in other file this.
secondfile.ts
import firstfile = require("src/firstfile"); export class secondfile { showa_again() { firstfile.showa(); }
i execute showa_again() in view file called secondfile.html
<button click.trigger="showa_again()" class="au-target">button</button>
when click button, see in console variable "a" still 3. there way store variables between files?
i'd recommend inject firstfile
secondfile
. code has smell of bad architecture.
to answer question: looking static (playground sample)
export class firstfile { static showa = function() { console.log("changed " + firstfile.a); } static = 3; public modifya() { firstfile.a = 7; firstfile.showa(); } } export class secondfile { showa_again() { firstfile.showa(); } }
Comments
Post a Comment