For nearly a year now, I've been immersed in a project where we started with Angular 2 during its rc versions, and we've since made our way up to version 5.
One requirement for our app is the ability to transpile TypeScript code into JavaScript and inject it for use.
Here's the scenario: I develop an app with pages, each containing controls that have unique IDs (which we already have in place). I then create a script that adds behaviors to these controls, such as defining actions for user interactions like clicks or changes. If an event is specified in the script for a certain control action, it should be executed accordingly.
Essentially, my app creates a framework with controls and a script file that listens to app events.
In the script, I need to register controls and link events to them, following the typical JavaScript practice.
Additionally, I would include a local API in the script for the app to leverage common functions. A simplified version of the app script is showcased below:
var myPage = myApp.Page("myPageID");
myPage.registerControls('txt1', 'txt2');
myPage.txt1.Events.Click(myClickFunction);
function myClickFunction(sender, event) {
//Perform actions here
}
When the app is active, the script is injected and is removed upon closure.
Is there a feasible way to accomplish this task?
I have been exploring options similar to JSFiddler, where I can input TypeScript code, transpile it into output JavaScript, export it as a file, and then inject it upon app launch.