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
?
$http
or$resource
service to cache data: docs.angularjs.org/api/ng/service/$http#caching – Yuriy Rozhovetskiy Jul 20 '14 at 16:41