I'm trying to retrieve data from a rest API by using the product id as part of the URL, rather than as a query parameter.
Here is the factory code:
.factory('Products', ['$resource',
function($resource) {
return $resource('products/:productId', {
productId: '@id'
}, {
query: {
isArray: false
},
update: {
method: 'PUT'
}
});
}
])
This is how the controller looks like:
$scope.getProduct = function(id, from) {
$scope.product = Products.get({ id: id }, function(){
console.log($scope.product);
});
}
When I access the URL, it currently appears as:
/products?id=5426ced88b49d2e402402205
Instead of the desired format:
/products/5426ced88b49d2e402402205
Does anyone have any insights on why this might be happening?