Within my index.html file, the following code exists:
<input type="text" ng-model="title" placeholder="Search..." >
<button type="submit" href="#" ng-click="getSearch()">Submit</button>
<select ng-model="selected" ng-options="obj.val as obj.display for obj in things"></select>
Accompanied by my controller implementation:
$scope.getSearch = function(){
svc.search($scope.selected)
.then(function(response){
$scope.searchData = response;
});
};
$scope.things = [
{display: 'Movie',
val: {s: $scope.title}},
{display: 'Series',
val: 'series'},
{display: 'Epsiode',
val: 'episode'},
];
Lastly, my service holds the following logic:
this.search = function(params){
return $http.get('http://www.omdbapi.com/',params)
.then(function(response) {
var results = response.data.Search;
return results;
});
};
Seems like everything is nearly operational. The only hiccup is with how the params are encoded when communicating with omdbapi.
$scope.getSearch = function(){
svc.search($scope.selected())
.then(function(response){
$scope.searchData = response;
});
};
$scope.things = [
{display: 'Movie',
val: function(){return {'type=movie&s': $scope.title};}},
{display: 'Series',
val: function(){return {'type=series&s': $scope.title};}},
{display: 'Epsiode',
val: function(){return {'type=episode&s': $scope.title};}},
];
And success! Finally cracked it after a long troubleshooting session.
val: function(){return {type: 'movie',s: $scope.title};}},