LinkedIn Login through Javascript

Requirement- Client Id

// Initialize linkedin API
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
 api_key: CLIENT ID
 authorize: true
 scope: r_basicprofile r_emailaddress
 onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
  // After Authentication of Account
 function onLinkedInLoad() {
 IN.Event.on(IN, "auth", getProfileData);
 }

 //After successfully Login 
 function onSuccess(data) {
 console.log(data);
  
 }

 // Error in API call
 function onError(error) {
 console.log(error);
 }

 // Get the needed Data
 function getProfileData() {
 IN.API.Raw("/people/~:(id,email-address,first-name,last-name,formatted-name)").result(onSuccess).error(onError);
 }
// destroy the session of linkedin
function closeSession(){
 IN.User.logout();
 return true;
}
</script>
<script type="in/Login"></script>

For custom Button

<script type="text/javascript">
//Invoke login window
function liAuth(){
 IN.User.authorize(function(){
 callback();
 });
}
</script>
<input type="button" onclick="liAuth()" value="Login"/>
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone
 

How to add the page loader in angularJS??

To add the page loader , we need to determine the http request sent by us has been responded or not.

For this simple query we need to evaluate just the value of following expression.

$http.pendingRequests.length.

Following directive can be used anywhere to install loader the page on loading:-

Example:-

angular.module('myApp.loading',[])

   .directive('loading',   ['$http' ,function ($http)
    {
        return {
            restrict: 'A',
            link: function (scope, elm, attrs)
            {
                scope.isLoading = function () {
                    return $http.pendingRequests.length > 0;
                };

                scope.$watch(scope.isLoading, function (v)
                {
                    if(v){
                        elm.show();
                    }else{
                        elm.hide();
                    }
                });
            }
        };

    }]);

In View Page :-

Where spinner is the class you want to add as animation or loading image.

More about
Http Request

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone