Asked By: Anonymous
Someone told me that frontend frameworks such as backbone, angularjs, knockout, etc work only for single-page apps since one has to define routes based on hashed arguments and these frameworks trigger appropriate controllers/modals/views.
My question is can these frontend frameworks be used for non-single page apps as well ? Let’s assume I have these three pages:
And I wrote code for routes in
app.js included in above files. Then will these frameworks be able to figure out which page we are on and trigger appropriate controllers (and other stuff with modals, loading appropriate views) automatically unlike single page apps based on hashes? If possible, optionally can somebody give simple example of how to define routes (non-hased in this case ofcourse) for above three pages using any of above framework ?
Thanks for the help
Answered By: Anonymous
As mentioned in the comments there is nothing that precludes you from using any of these frameworks in a traditional, round-trip-per-page web application. That being said, you should pick the right tool for the job.
I have used both Angular and Knockout extensively on real world applications. I have only used backbone a little, but I prefer the declarative style of Angular and Knockout over the imperative style of backbone.
Backbone and Angular are really designed and optimized for building single page applications. However, there are many shades of grey in between. You could load up a “Customers” page and have a handful of routes defined there, but when you navigate over to “Admin” that could be a total page refresh and you would have multiple routes defined there.
Knockout is not a SPA framework. It does not come with a router, and therefore doesn’t handle side loading of views. You use something like Sammy.js to achieve the routing you want.
If you aren’t building a SPA then don’t use a SPA framework.
I would personally go with Knockout if I were you since you don’t need a router.