Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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