Here, we have to mention default $scope.loginstatus and we should assign the value of the pageload.

Step 4

The user clicks the button directly with the authentication to Facebook and checks the connection status.

were we can see the connections in response.status, which is mentioned below.

$scope.login = function() {

Facebook.login(function(response) {

$scope.loginStatus = response.status;

testAPI();

});

};

Step 5

If response status value is connected, testAPI will call, where user data can be noted.

Facebook.api('/me', function(response) {

$scope.user = response;

});

};

When the user uses another tab, we can connect our project at the same time as default page load, and we can check the user connection status on Facebook athauntication .

Now, API will respond to return the connection or it will show as unknow error. ( $scope.facebookIsReady = false; ), Its default page to connect the facebook Is ready to check the auto in status as true or false .

We have to globally assign false in facebookIsReady.

$scope.$watch(function() {

return Facebook.isReady();

}, function(newVal) {

if (newVal) {

$scope.facebookIsReady = true;

}

});

Step6

When the response.status is connected, it will return the accesss token key & userID. Now we can also get the value by calling testAPI. The necessary details should be mentioned as id,name,first name ,lastname, email,age and picture.