Updating the home controller
If you take a look at our current home controller (controllers/home.js
), you can see that the index function barely has any code in it whatsoever:
res.render('index');
The first thing we want to do is build a basic view model using sample data so that we can see our view model at work. Replace that single res.render
call with the following updated code:
var viewModel = { images: [ { uniqueId: 1, title: 'Sample Image 1', description: '', filename: 'sample1.jpg', views: 0, likes: 0, timestamp: Date.now }, { uniqueId: 2, title: 'Sample Image 2', description: '', filename: 'sample2.jpg', views: 0, likes: 0, timestamp: Date.now }, { uniqueId: 3, title:...