-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFillAwareAngularJS.js
More file actions
37 lines (34 loc) · 1.39 KB
/
Copy pathFillAwareAngularJS.js
File metadata and controls
37 lines (34 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var app = angular.module("myApp", []);
app.controller("ACController", function($scope, $q, $http) // Your controller
{
$scope.suggestionList = [];
$scope.hideSuggestions = true;
var promiseCanceller = $q.defer(); // creating a promise, so there would not be 10 calls in a queue.
$scope.updateAC = function($event,construct) // Function name to call
{
if(construct.length < 3) // Less calls and more accurate search. Change this number to whatever you want
{
return;
}
var type = $event.target.getAttribute("resourceType"); // This is your attribute. resourceType can be: names, companies, first_names, last_names, emails, addresses, colors
var APIKey = "iSkwEtRMxzOFzWwoy8GEvsL7DMlpn94Uffrg8ETYMOlrsspEZI7Ck_ElqvevdIxz";
$scope.hideSuggestions = false;
promiseCanceller.resolve('New request!'); // Cancel previous calls.
promiseCanceller = $q.defer();
$http.get("https://api.fillaware.com/v1/suggest/" + type + "?q=" + construct + "&key=" + APIKey, {timeout: promiseCanceller.promise}).
then(function(response)
{
$scope.suggestionList = angular.fromJson(response.data);
},
function (error)
{
$scope.hideSuggestions = true;
$scope.suggestionList = [];
})
};
$scope.selectSuggestion = function(selection)
{
$scope.compName = selection;
$scope.hideSuggestions = true;
}
});