'Is it possible to use Angular as a binary that generate visualization html?
I have some Angular templates that takes some data and organize and visualize the data. I would like to serve it on an angular web server so others can input their custom data, but sometimes I also have a list of data I want to try and save the visualization results on disk.
Is it possible to write some kind of typescript binary main script that I can call on the command line, that constructs an angular object, then renders it as html string, then writes the html to disk?
Solution 1:[1]
I am not entirely sure what do you want to achive here. Here are some notes:
There is no such thing as an "Angular Web Server". Angular is a library, made up from a "builder" and a "library" part. The "builder" builds a static webpage (to HTML, CSS and JavaScript files) and the "library" is just JavaScript code compiled "into" your program. These can be then served by ANY KIND of static webservers, as the output is simple HTML, CSS and JavaScript files. Your Angular template files are only used when you are building your application: the "builder" will turn it into a basic website.
The (Angular) website is then downloaded to a browser on the users end. This application runs on the client side. If you want to store the data which the users insert, then you need to create a server application, to which the website communicates and sends these data. It can store it however you like, but that is an entirely different program. Angular is not used for that.
For the last entry it seems that you don't really understand how Angular works. There is no such thing as an "angular object": Angular is a JavaScript framework, so it uses JavaScript objects. There is no such thing as typescript binary, as TypeScript is an extension for the JavaScript (script) language, which consist os a TypeScript compiler which turns TypeScript code to JavaScript. That's right: Your Angular code, written in TypeScript is compiled into plain old HTML, JavaScript and CSS files at the end of the day.
To achive what you describe, you probably want to store some kind of a JSON (JavaScript Object Notation, the main format of JavaScript data communication on the internet) document on your server. For that we usually create a Fullstack Application system with multiple programs, which can do that for you: Az Angular Frontend which runs in the users browser; an Express.JS Backend which can be the backend server program accepting the data from the clients, and a MongoDB database which will store the data for you (it's called the "MEAN" stack, you can look up some tutorials on them). This way all the components of your program will be written in JavaScript, are decoupled correctly and can be developed independently of each other. There are other appriaches as well, for instance using Java as a backend, or PHP to create the whole website on the server, combining the frontend and backend app even.
I didn't really grasp the visualization problem you describe, but I recommend not storing "screenshots" of data, if you can store the data directly: you can always create different visualizations from it, not to mention that it's way smaller and don't need that much space to store (think about saving an excel file or saving screenshots of the excel file).
To better undestands the basics of how web applications usually work, I recommend https://roadmap.sh/ and a lot of patience :) Good luck!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
