Last active
December 21, 2015 06:29
-
-
Save jccrosby/6264585 to your computer and use it in GitHub Desktop.
Using $http instead of $resource for the EPL services
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
// Creating the service | |
factory('GetMajorEventsTimelineSvc', ['$q', '$http', '$window', function($q, $http, $window) { | |
return function() { | |
return { | |
get: function() { | |
var uri = 'http://overlays.nbcsports.com/services/lowttl/pl.asmx/GetMajorEventsTimeline'; | |
var method = 'JSONP'; | |
var params = {}; | |
params.GameID = 694904; | |
params.callback = 'onGetMajorEvents'; | |
var deferred = $q.defer(); | |
$http({method:method, url:uri, params:params}); | |
$window.onGetMajorEvents = function(data) { | |
deferred.resolve(data); | |
} | |
return deferred.promise; | |
} | |
} | |
} | |
}]); | |
// load call w/ response handlers | |
httpSvc.get() | |
.then( | |
function(data) { | |
// set data here | |
console.log(data); | |
}, | |
function(data) { | |
// handle error here | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment