I've been working in project for almost an years, we are using Angular 2 since its rc versions. At the moment we are already in version 5.
Our app has a need to have javascript code transpiled from typescript injected and being able to use it.
Imagine the following: I can create an app with pages inside each page has controls, then each control has an ID; (We already have this) I create a script that I can add behaviours to those controls. Things like when the user clicks inside a control, or change event. If I have in the script and event for that click event, I would execute what is in it.
So my application, creates an "app", and this app has controls and one script file that will listen to the events coming from the app.
In the scripting I would have to register the controls and assign the event to it, like we normally do in Javascript.
For instance i would have a local api that i would also inject so the app could reuse some common functions, below is how the script for the app would be:
var myPage = myApp.Page("myPageID");
myPage.registerControls('txt1', 'txt2');
myPage.txt1.Events.Click(myClickFunction);
function myClickFunction(sender, event) {
//Do something here
}
So when I have this app open in my application, the script would be inject when i open the app, and removed when i closed.
Is there any way to achieve this?
I still trying to find a kind of JSFiddler where i can add typescript code and get the result transpiled export to a file to have it injected when I open the app.