Created
February 26, 2013 18:48
-
-
Save heckmac/5040979 to your computer and use it in GitHub Desktop.
angularjs: facebook image request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="module" ng-controller="fbImageReqCtrl"> | |
<img ng-src='{{url}}' /> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('module', []).factory('api', function($q, $http){ | |
return { | |
getPic:function(id){ | |
var def = $q.defer(); | |
$http.jsonp('https://graph.facebook.com/' + id +'/picture?redirect=false&callback=JSON_CALLBACK').success(function(r){ | |
def.resolve(r.data.url); | |
}); | |
return def.promise | |
} | |
} | |
}); | |
function fbImageReqCtrl ($scope, api){ | |
$scope.url = api.getPic('shaverm'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment