I started learning AngularJS recently. But I thought that it would not be very cool if hosting a site on it would be difficult and therefore it is worth considering this problem in advance.

As I learned from the English-language resource, NodeJS is not necessary to run my application, since all actions can be processed locally by the client.

What then is the point of AngularJS? From part to simplify the work? In terms of processing, there will be some PHP on the server, right? Then AngularJS simply simplifies working with elements on the page.

One last thing: is it possible to simply connect the TS script to the page in order to execute it? That is, the program does not need to be rewritten under the "client" version. That is, once again, and server and client options look the same?

  • Angulyar essentially unties the hands for development on the client side, which allows you to build more responsive applications - Bald

1 answer 1

AngularJS is a client framework. (By the way, if you mentioned TypeScript, you probably meant Angular, not AngularJS. But the answer does not change). Being a client framework, it does not need a server (but you may still need the server for the server part of your application) and it does not have any “server” option.

You will need the Node.js for the following things:

  1. Compiling (also called transfiling) scripts. For example, you mentioned TypeScript. Browsers cannot execute TypeScript, they must be compiled using tsc (TypeScript Compiler) before using these scripts. To run tcs, you need node.js, because tcs is just a script.

  2. Build resources. You can do without this step, but it is usually recommended to pack all used resources into several files ("bundles") for faster loading by the browser. Many tools have been invented for this purpose - but usually they are also run using node.js

After compilation and assembly you will have a set of static files - and you can upload these files to any hosting. You do not need node.js on hosting - but you will need node.js on your computer.

The server part for your application will most likely do the following:

  1. There will be your client scripts
  2. It will work from the database and respond to the client for AJAX requests.

For point 3 any web server is suitable, this is the basic functionality of web = servers. For point 4, any server language will be suitable - PHP, C #, Ruby ...

You can completely abandon the server part, if the logic of your application allows you to do without it. For example, if you are doing a browser extension.

  • You broke my brain just now. That is, we compile TypeScript and get a set of JS scripts only 1 time? I thought it was happening so quickly that it is customary to compile the script server all the time. Only 1 more question: can the client compile TypeScript itself? Thank you for the great answer! - Telion
  • @Telion in theory - maybe, but no libraries are written for this. - Pavel Mayorov