Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Angular 4, are controllers executed on the browser or server?

Tags:

angular

I am building an Angular 4 app. For local development I am running the app using ng serve.

It seems that Angular is running completely in the browser. Is ng serve a development only tool? Is it possible to run Angular controllers on the server and not the browser?

like image 317
Nelson Avatar asked Nov 15 '25 20:11

Nelson


2 Answers

Angular is indeed a front end framework, and as such it runs in the browser. ng serve runs a webpack development server so that you can see what your application looks like without having to spin up a separate webserver and bundle your code. When you deploy, you'll have an existing webserver host your angular code, but the controllers will just be responsible for client side (browser) markup. For server side routing (controllers on the server), you wouldn't use angular but some sort of server side web framework. For example, you can use NodeJS on the server side with server side controllers (often times these will return JSON data that your angular app will work with).

like image 168
istrupin Avatar answered Nov 18 '25 09:11

istrupin


Angular is a purely client-side framework. The ng serve command just starts a lightweight development server that runs in the local environment. Running Angular on a server in production would seem to defeat the purpose of using an AJAX-based single page application framework, as its benefits come specifically from the fact that it's run in the browser.

like image 31
Kai Avatar answered Nov 18 '25 09:11

Kai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!