Skip to content

Instantly share code, notes, and snippets.

@heckmac
Created February 26, 2013 18:48
Show Gist options
  • Save heckmac/5040979 to your computer and use it in GitHub Desktop.
Save heckmac/5040979 to your computer and use it in GitHub Desktop.
angularjs: facebook image request
<div ng-app="module" ng-controller="fbImageReqCtrl">
<img ng-src='{{url}}' />
</div>
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