I am trying to create a search bar using omdb api and am trying to send one or multiple filters through. It should send whatever filter is selected but apparently it isn't doing that. Here is the code. I have checked some similar problems on stackoverflow but none of them gave me the solution that worked or hinting at what I could be looking for. NOT EVEN Build query string from parameters object solved it. See, for example, I have three fields, title, year and type. The user may fill all three of them or any one of them. According to what they select, the parameter should be formed. If there are any solutions, I would love to go by them, if not, please help me achieve it. Please see this example if you need to: http://www.omdbapi.com/#examples and if you find it similar to some solution, I'd be glad to look it over. Thanks in advance.
app.controller('searchController', ['$scope', function($scope,$http,$window,$location){
// Storing user details
$scope.movie={
t:null,
y:null,
type:null
}
// Calling HTTP response
function myHTTP(){
$http({
method : 'GET',
headers: {'Content-Type': 'application/json'},
url : 'http://www.omdbapi.com/?t='+$scope.movie.t+'&y='+$scope.movie.y+'&type='+$scope.movie.type
}).then(function mySuccess(response) { //function for taking actions when the status code is 200 and authentication is a success.
// Binds messages to display to html pages
$scope.status = response.status;
$scope.movie.title=response.Title;
$scope.movie.year=response.Year;
$scope.movie.imdbid=response.imdbID;
$scope.movie.type=response.Type;
$scope.movie.poster=response.Poster;
}).catch(function error(response) { //function for taking actions when response is an error.
// Binds messages to display to html pages
$scope.status = response.status;
});
}
// function calling all other functions
$scope.parameters = function() {
myHTTP(); //calling service function and creating JSON
$scope.template ='html/mlist.html';
}
}]);