I use TypeScript, wrote a certain file on class initialization + loading of initial parameters.

import PageContainer from './Page/pages'; import {Animation} from "./Page/pages"; export var pageContainer = new PageContainer('container', new Animation('', '')); pageContainer.select('Sign In'); 

Next, I collect this whole thing with a webpack and connect it like this in html:

 <script src="../../out/bundle.js"></script> 

The question is how to make this pageContainer available in this html file? So that this code, for example: <a href="javascript: pageContainer.switch('Sign Up')">Register</a> could earn?

  • one
    The good old record in the global object window.pageContainer = .... Another question from where “such code here” came from, if someone wrote it himself with pens (and not some tool generated), then so to do in general is not very good, in normal sized applications at least. - Duck Learns to Take Cover
  • Thank you. Hm, what's the best way to do It just seemed to me that right in html quite clearly turns out - Uraty
  • one
    For a very small application will go in general. For a small but that will grow, something like <a class="js-tab-switch"> can be added and objects on such a class can be loaded by a handler somewhere when the application is initialized. For a normal or risky grow, it’s better to take a ready-made router. The purpose of these dances is to isolate logic from presentation. Including global variables less rivet - Duck Learns to Take Cover
  • Yeah, I understand you, thank you very much) - Uraty

0