daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ngApp = angular.module('test', []);
  2.  
  3.     window.ngApp.controller('controllerBase', ['$scope', '$controller', '$timeout', "$window", function ($scope, $controller, $timeout, $window, facebookService) {
  4.         $scope.getMyLastName = function () {
  5.             console.log("facebookService", facebookService);
  6.             return;
  7.             facebookService.getMyLastName().then(function (response) {
  8.                 console.log("response", response);
  9.                 $scope.last_name = response.last_name;
  10.             });
  11.         };
  12.  
  13.         $window.fbAsyncInit = function () {
  14.             FB.init({
  15.                 appId: 'xxx',
  16.                 status: true,
  17.                 cookie: true,
  18.                 xfbml: true,
  19.                 version: 'v2.4'
  20.             });
  21.         };
  22.     }]);
  23.  
  24.  window.ngApp.factory('facebookService', function ($q) {
  25.     return {
  26.         getMyLastName: function () {
  27.             var deferred = $q.defer();
  28.             FB.api('/me', {
  29.                 fields: 'last_name'
  30.             }, function (response) {
  31.                 if (!response || response.error) {
  32.                     deferred.reject('Error occured');
  33.                 } else {
  34.                     deferred.resolve(response);
  35.                 }
  36.             });
  37.             return deferred.promise;
  38.         }
  39.     }
  40. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top