Last active
August 29, 2015 14:20
-
-
Save samuelbeek/d4a803dec46453db0ba1 to your computer and use it in GitHub Desktop.
MovieService to use OMDB API with Angular
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
// 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