Book Image

AngularJS Web Application Development Blueprints

By : Vinci J Rufus
Book Image

AngularJS Web Application Development Blueprints

By: Vinci J Rufus

Overview of this book

If you are a web application developer interested in using AngularJS for a real-life project, then this book is for you. As a prerequisite, knowledge of JavaScript and HTML is expected, and a working knowledge of AngularJS is preferred.
Table of Contents (12 chapters)
11
Index

Getting your friends' profile pictures and birthdays


As of now, we are only displaying the names of our friends; we now need to display their profile picture and their birthdays (if they have updated it on their Facebook profile) too.

By using the Graph Explorer, you'll see that the endpoint that we need to call to get the required information is /me/friends?fields=birthday,name,picture.

Let's update the endpoint in our directive controller function by adding the following highlighted code. We make this change in the app/directives.js file, shown as follows:

$scope.loadFriends = function() {

  FB.api('/me/friends?fields=birthday,name,picture', function(response) {
    $scope.$apply(function() {
      $scope.myFriends = response.data;
    });

  });
}

We'll also need to update our view to create the placeholders for these additional pieces of information. So, let's modify our app/partials/partial1.html file as follows:

<div my-facebook></div>
<h1>My Friend's Birthdays</h1...