Appendix C. Dealing with all the views

 

This appendix covers

  • Removing the data from all views except the homepage
  • Moving the data into the controllers

Chapter 4 covers setting up the controllers and the views for the static, clickable prototype. The “how” and “why” are covered in that chapter in more detail, so this appendix focuses on the results.

Moving the data from the views to the controllers

Part of this process includes moving the data back down the MVC flow, from the views into the controllers. The example in chapter 4 deals with this task in the Loc8r homepage, but it needs to be done for the other pages too. Start with the Details page.

Details page

The Details page is the largest and most complex of the pages, with the most data requirements. The first step is setting up the controller.

Setting up the controller

The controller for this page is called locationInfo and is in the locations.js file in app_server/controllers. When you’ve analyzed the data in the view and collated it into a JavaScript object, your controller will look something like the following listing.

Switching from Promises to Observables

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage