darylrowland / angucomplete

AngularJS Autocomplete Directive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use remote url with a function (like ng-change)

salimchami opened this issue · comments

Hello!
thanks for this directive.

I want to use the remote version of the directive. But, i can't put function directly in remote-url and remote-url-data-field attributes because in backend, i have rest service that attending a jwt token and two or more paramaters.
The service method is like that :

getByFullname: function(fullname){
AuthHttp.get('/rest/' + ProfileService.getCurrentUser().id + '/persons/fullname/' + fullname).success(function (data) {
// the promise gets resolved with the data from HTTP
deferred.resolve(data);
});
// return the promise
return deferred.promise;
}

and in my controller, i have a function wich call the service method.

$scope.search = function(){
if($scope.searchedPerson && $scope.searchedPerson.length > 1){
var data = PersonsService.getByFullname($scope.searchedPerson);
data.then(function(data){
$scope.persons = data.persons;
});
}
};

How can i use the remote caller attribute with a function ?
It can be like ng-change function...

Thanks a lot.