Hi all,
I would like to take some variables generated from index.html and not inside aurelia.
How can I do this?
For example this ( but can be everything):
into :
Thanks you,
Andrea
Hi all,
I would like to take some variables generated from index.html and not inside aurelia.
How can I do this?
For example this ( but can be everything):
into :
Thanks you,
Andrea
Hello @AndreaProgrammerIT2, the general idea is to not to deal with global variables in that sense. Whatever you want to do in a script tag in index.html can be put into the bootstrapping/startup function of an Aurelia app.
Alternatively if you really have to deal with e.g. server rendered state or predefined data you’d have to put it into window. Also make sure to put it inside a namespace for lesser collision conflicts. E.g window.yourApp.userLang = …
The variables in your index.html are created as global JS variables.
Just access them as global variables.
attached() {
alert(userLang);
// Or explicitly from window which all global variables were attached to
alert(window.userLang);
}