Creating our product details page
Next, we will build our product details page. We'll try this by writing out the factory service that will return the data for the selected product. Within the AWSservice provider, create the following function:
getProductDetails: function(id) {
var d = $q.defer();
var params = {
'Key': {'product_id': {'S': id}
}
};
dynamo.getItem(params, function(err, data) {
if (err) $log.error('err= ' + err);
if (data) {
d.resolve(data);
}
});
return d.promise;
},The code will look familiar to you by now. We build the params object with the key parameter. Note that the key parameter always needs to be the hash value. In case you defined a RangeKey while creating your table, you will also need to set the RangeKey values while building the params object.
Once the object is ready, we pass it to the getItem method and wait to hear from DynamoDB.
Next, we'll replace the static data with the actual code...