I have an if-else block that parses user input before making a http.get() to the server. However, the if-else keeps on being skipped over. I tried rearranging my code to force it to complete the if-else before calling get(), but nothing seems to work. I'm also using AngularJS.
//controller
function search($scope, $http, $location)
{
function parse(item)
{
if(item.match(/str1/g))
{
item = item.replace(/str1/g, 'one');
}
else if(item.match(/str2/g))
{
item = item.replace(/str2/g, 'two');
}
else if(item.match(/str3/g))
{
item = item.replace(/str3/g, 'three');
}
//ad infinitum
return item;
}
$http.get('/search='+ parse($location.search().query.toLowerCase()))
.success(function(data) {
$scope.count = data.length;
$scope.items = data;
$scope.exists = data.length > 0;
})
.error(function(err) {
});
}
returnstatements.