Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
AngularJS Web Application Development Blueprints

You're reading from   AngularJS Web Application Development Blueprints A practical guide to developing powerful web applications with AngularJS

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher Packt
ISBN-13 9781783285617
Length 300 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Vinci J Rufus Vinci J Rufus
Author Profile Icon Vinci J Rufus
Vinci J Rufus
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Introduction to AngularJS and the Single Page Application FREE CHAPTER 2. Setting Up Your Rig 3. Rapid Prototyping with AngularJS 4. Using REST Web Services in Your AngularJS App 5. Facebook Friends' Birthday Reminder App 6. Building an Expense Manager Mobile App 7. Building a CMS on the MEAN Stack 8. Scalable Architecture for Deployments on AWS 9. Building an E-Commerce Store A. AngularJS Resources Index

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

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime