Skip to content

Instantly share code, notes, and snippets.

@kvofreelance
Created January 20, 2014 17:26
Show Gist options
  • Save kvofreelance/8524594 to your computer and use it in GitHub Desktop.
Save kvofreelance/8524594 to your computer and use it in GitHub Desktop.
$scope.$watch('search', function() {
console.log($rootScope.searchIngridient);
console.log($scope.search);
$rootScope.loadingListView = true;
if($scope.firstLoading) {
$scope.firstLoading = false;
$rootScope.loadingListView = false;
} else {
parameters = {};
parameters.query = $scope.search;
$rootScope.searchIngridient = $scope.search;
$http.post('/search/ingredient', parameters).success(function (data) {
console.log("Ingridient search SUCCESS");
console.log(data);
for(var i=0; i< data.length; i++) {
data[i].effect = data[i].effect.charAt(0).toUpperCase() + data[i].effect.slice(1);
}
console.log(data);
$scope.ingridients = data;
$rootScope.ingridients = data;
$rootScope.loadingListView = false;
})
.error(function (data, status, headers, config) {
$rootScope.loadingListView = false;
console.log("Ingridient search error. Status: " + status + "; data: " + data + "; headers: " + headers + "; config: " + config);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment