Created
January 20, 2014 17:26
-
-
Save kvofreelance/8524594 to your computer and use it in GitHub Desktop.
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
$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