poniedziałek, 18 listopada 2013

AngularJS resource with JSONP

Lately I struggled to get access to facebook by JSONP. I try to do it in AngularJS with factory and resource. I want to share with people my solution. Let's try to connect to the Facebook Graph. Firstly, we create index.html file with input graph.username, after type a value there is called getGraph(). The result of the calling this function is saved in $scope.result so we can display it. Secondly, in app.js we write controller and factory which creates a resource object that call the Facebook Graph. So when it is called function getGraph we use GraphFacebook factory to call getJSONP passing in argument $scope.graph with username property. This property is used in building URL.
The result of our work:


Source on GitHub

Brak komentarzy: