Skip to content
This repository has been archived by the owner on Oct 6, 2021. It is now read-only.

Commit

Permalink
Make extractValue a private function
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenharman committed Feb 7, 2014
1 parent b8a75cb commit 9492cb9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions angucomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ angular.module('angucomplete', [] )
$scope.pause = $scope.userPause;
}

extractValue = function(obj, key) {
if (key) {
value = eval("obj." + key);
} else {
value = obj;
}
return value;
}

$scope.processResults = function(responseData, str) {
if (responseData && responseData.length > 0) {
$scope.results = [];
Expand All @@ -64,12 +73,12 @@ angular.module('angucomplete', [] )

var description = "";
if ($scope.descriptionField) {
description = $scope.extractValue(responseData[i], $scope.descriptionField);
description = extractValue(responseData[i], $scope.descriptionField);
}

var image = "";
if ($scope.imageField) {
image = $scope.extractValue(responseData[i], $scope.imageField);
image = extractValue(responseData[i], $scope.imageField);
}

var text = eval(titleCode);
Expand Down Expand Up @@ -126,7 +135,7 @@ angular.module('angucomplete', [] )
$http.get($scope.url + str, {}).
success(function(responseData, status, headers, config) {
$scope.searching = false;
data = $scope.extractValue(responseData, $scope.dataField)
data = extractValue(responseData, $scope.dataField)
$scope.processResults(data, str);
}).
error(function(data, status, headers, config) {
Expand All @@ -137,15 +146,6 @@ angular.module('angucomplete', [] )

}

$scope.extractValue = function(obj, key) {
if (key) {
value = eval("obj." + key);
} else {
value = obj;
}
return value;
}

$scope.hoverRow = function(index) {
$scope.currentIndex = index;
}
Expand Down

0 comments on commit 9492cb9

Please sign in to comment.