0

I'm looking into using AngularJS for an upcoming project but I am having difficulty getting my head around the views/routing, specifically for an app with only one page.

The page consists of a form or wizard, however I want all data to be loaded on the initial page load (and stored in local storage). This also applies to form elements - no additional requests can be made to the server e.g. for HTML templates (except the submit action at the end of the form). The application will be used offline so the single page needs to cache all required information and handle UI transitions without reloading.

Is AngularJS a good fit for such an application? If so, how can I accomplish the routing required to change views without additional requests - can ng-view and a routeProvider use div's within a single html page? Is this a case for ui-routes?

jmc
  • 620
  • 14
  • 24

1 Answers1

1

I've yet to implement such a site but I believe these are slightly orthogonal issues. AngularJS solves the issue of polluting your view with business logic (MVC), it also gives you the means to create singleton services. Further it allows you to extend the vocabulary of HTML with directives to define compound DOM elements or behaviors. All of these elements I believe are helpful in creating a user interface that is loosely coupled via a model and a controller for a view to the data retrieved and stored in services.

Local storage APIs implemented in certain browsers in response to definitions in the HTML5 spec give you the ability to persist data locally and determine when a change from online-offline has occurred, it's covered in depth on this page http://www.html5rocks.com/en/tutorials/offline/whats-offline/

Long and short of it I think AngularJS is an ideal candidate for building rich client side experiences and decoupling the model from the view and the controller (hence giving you the part you need to save separate from the application itself). All that said I'm not aware of any mechanisms built in to Angular to help make this easier, though if you Google a bit for localStorage and AngularJS there is definitely some discussion about it and code available: angularjs and localStorage change event

Community
  • 1
  • 1
shaunhusain
  • 19,630
  • 4
  • 38
  • 51