I have a page where I display a list of products. When the user clicks on a product I show the product details in another page. This is a part of my routing configuration:
when('/products', {
templateUrl: 'views/products.html',
controller: 'ProductListCtrl'
}).
when('/products'/:productId', {
templateUrl: 'views/product-details.html',
controller: 'ProductDetailsCtrl'
}).
As you can see I can only pass productId (which I retrieve using $routeParams) as parameter, which means I need to make another AJAX call to get information about product. But I already have this data on the products page.
So my question is: can I pass a whole Product object to ProductDetailsCtrl instead of just passing productId?
$httpor$resourceservice to cache data: docs.angularjs.org/api/ng/service/$http#caching