greg
greg

Reputation: 1873

Does an Angular client UI run entirely in the browser

Encountered some Angular developers who were discussing Angular's server side code. This surprised me.

Does Angular have server side code?

I was under the impression that all the code ( libraries, routing, components) all of it, is downloaded to the client.

My question is explicitly this : As you navigate through different routes, controllers, etc. in an Angular application, does the browser make repeated calls to the node web server.

Webapi calls are obviously calls to some server somewhere. That's not part of this question.

My impression from the limited amount of work I have done in angular(v8) is that it is entirely browser side.

This may be a simple question, but I have been unable to find a definitive answer.

Upvotes: 3

Views: 1053

Answers (3)

greg
greg

Reputation: 1873

As you navigate through different routes, controllers, etc. in an Angular application, does the browser make repeated calls to the node web server.

The answer is in fact yes. Try stopping the ng serve process and see what happens. Take a look at DevControls network tab as you navigate the app.

My question was bolded, and is not ambiguously worded. The angular front end in fact makes repeated calls to the web server to download components.

This is surprising to me, but seems fairly clear given my observations.

I believe that these are merely downloads. Angular does not download the entire app when you hit the homepage. I still contest the conversation I overheard that there is server side code 'running'. I have encountered nothing to support that. But that's another question...

Upvotes: 1

Rip Ryness
Rip Ryness

Reputation: 651

Both Angular and React have related projects that enabled Server-Side Rendering (SSR) for these Single Page Application (SPA) frameworks. For Angular, the project is called Angular-Universal.

In this scenario, there is server-side NodeJs code that can recognize Angular routes and then render that route completely before it sends it downstream to the browser. The browser can then render the page without needing the SPA (javascript) code, after which it can then start the SPA.

Upvotes: 1

Nicholas K
Nicholas K

Reputation: 15443

Does an Angular client UI run entirely in the browser

Yes. The browser downloads the required bundles when the page loads.

Upvotes: 1

Related Questions