Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS : single page and multipage app difference and use in practice?

I've been studying the difference between single page apps and multi page apps, and I think I have good view how they differ. Single page app starts by loading a single html page, and then it does never again fully refresh the page or override the original, unless the application is otherwise refreshed (browser refresh etc.) For example, the angularJS seed project: angular-seed has an index.html file. This file is the single page, that the server would send to front-end, and after that, all the other (possible) pages will be send asynchronously under the hood by using AJAX. So if you create app just with the angularjs seed, it is always going to be just a SPA application, am I right?

How in practice would you then create a multipage application with angularjs? Wouldn't you need multiple angularJS applications then? Would you have to have a separate routing for each of those angularJS applications? And why would one want to make multipage application for angularJS? Because one could always use the first index.html just as a shell, without real content, and then have separate container-pages for different pages. Could it be said that angularJS multipage app would be an application, that would just contain many SPA angularJS applications? In SPA, can you use the browsers' back-button, in order to go back to last view?

like image 538
Ville Miekk-oja Avatar asked Apr 15 '15 09:04

Ville Miekk-oja


People also ask

What is the difference between single-page application and multi-page application?

Ans 1) A Single Page Application is where the server sends what you need with each click, and the browser renders that information without the need to reload the page again. Whereas in the case of a multi-page application every change requests rendering a new page from the server in the browser.

When should I use multi-page app?

The high scalability of MPA is essential when it comes to complex and large websites. Since there are no page limitations, you can develop and release new content pages with the least impact on the existing code. This resembles the usage of MPAs in large e-commerce sites, where SEO and scalability dominates.

When should you not use a single-page application?

Single-page applications don't allow a lot of features on one page, which can lead to longer loading times. Therefore, when company needs more features, they decide to use multi-page applications.

Are single page applications faster?

Single-page applications are a great way to improve the user experience of your website. They offer many advantages over traditional multi-page applications, including faster load times, better compatibility with older browsers, and an improved user interface.


1 Answers

Yes, you've got the idea of SPA and MPA right.

Angular.js enables you to create SPAs but does not force you. In an MPA, I would not speak of multiple Angular applications since you would have just spread Angular.js modules over multiple HTML pages. The page flow or routing logic would then be in Angular.js controllers, in plain hyperlinks or in the backend on the server.

There might be reasons to not put a whole application under Angular.js. Maybe the authentication part of a web application might be Held separately for some reasons...

In SPAs you definitely can use the browser's back button. You just have to implement that somehow. Twitter solves this Problem by coding the state of its web application into the URL - if you're using Twitter, you might have noticed the symbols (#!) in the address bar.

like image 138
rowing-ghoul Avatar answered Oct 07 '22 10:10

rowing-ghoul