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 ...

Get AngularJS Web Application Development Blueprints 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.