Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Solution based on Maxim's answer above - JsFiddle - <a href="http://jsfiddle.net/acb98sm/2pQ6A/6/" rel="nofollow">http://jsfiddle.net/acb98sm/2pQ6A/6/</a></p> <pre><code>var myApp = angular.module('myApp',[]); myApp.controller('SiteConfigCtrl', ['$scope', '$rootScope', '$route', 'SiteConfigService', function ($scope, $rootScope, $route, SiteConfigService) { SiteConfigService.getConfig() .then(function (result) { console.log("results are in "); console.log(result); $scope.site = result.data; }, function (result) { alert("Error: No data returned"); }); } ]); myApp.factory('SiteConfigService', ['$http', '$rootScope', '$timeout', 'RESTService', '$q', function ($http, $rootScope, $timeout, RESTService, $q) { var siteConfigFn = RESTService.get("http://graph.facebook.com/616366118/", function(data) { console.log("SiteConfigService returns"); }); return { getConfig:function () { var deferred = $q.defer(); deferred.resolve(siteConfigFn); return deferred.promise; } }; } ]); myApp.$inject = ['$scope', 'SiteConfigService', 'RESTService']; myApp.factory('RESTService', function ($http) { return { get:function (url, callback) { return $http.get(url, {withCredentials:false}). success(function (data, status, headers, config) { callback(data); }). error(function (data, status, headers, config) { console.log("failed to retrieve data"); }); }, post:function (url, data, callback) { return $http.post(url, data, {withCredentials:true}). success(function (data, status, headers, config) { callback(data); }). error(function (data, status, headers, config) { console.log("failed to retrieve data"); }); } }; } ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload