Skip to content

Instantly share code, notes, and snippets.

@samuelbeek
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelbeek/d4a803dec46453db0ba1 to your computer and use it in GitHub Desktop.
Save samuelbeek/d4a803dec46453db0ba1 to your computer and use it in GitHub Desktop.
MovieService to use OMDB API with Angular
// movieService can be used in a controller like this:
// movieService.getMovieDetails("Pulp Fiction").success(function (data) {
// $scope.movie = data
// }
app.factory('movieService', ['$http', function ($http) {
return {
getMovieDetails: function (title) {
var getData = {
method: 'jsonp',
url: 'http://www.omdbapi.com/?t=' + title, //add +'&apikey=YOUR_API_KEY' if you have one.
headers: {
'Content-Type': undefined
},
params : {
callback : 'JSON_CALLBACK'
}
};
return $http(getData)
}
}
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment