Implementing the search and navigation functionality

Now that we have the backend ready to support the products categories and search, we can move to AngularJS and prepare the navigation and search.

Adding custom $resource methods

We are going to add some new actions to our product service to match the ones created at the backend:

/* client/app/products/products.service.js */

angular.module('meanshopApp')
  .factory('Product', function ($resource) {
    return $resource('/api/products/:id/:controller', null, {
      'update': { method: 'PUT'},
      'catalog':{ method: 'GET', isArray: true,
        params: {
          controller: 'catalog'
        }
      },
      'search': { method: 'GET', isArray: true,
        params: {
          controller: 'search'
        }
      }
    });
  });

We have modified the URL with a new attribute; controller ...

Get Web Application Development with MEAN now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.