This is related to my previous question : Angular typeahead : watch for dataset change
I am using Siyfion's typeahead directive for my project since its a few lines of code simple to understand (for beginners like me ).
Now I have a django backend server which returns JSON objects which I would like to use for autocomplete.
Right now my controller looks like this :
$scope.getGuests = function (guestValue) {
return $http.jsonp('http://gd.geobytes.com/AutoCompleteCity?callback=JSON_CALLBACK &filter=US&q=' + guestValue)
.then(function (response) {
return limitToFilter(response.data, 15);
});
};
My markup :
<input type="text" class='sfTypeahead' datasets='getGuests($viewValue)' ngModel='testname' />
Now this obviously doesn't work because my widget doesn't load until it has datasets
ready completely.
Is there a way where I can write directives such that I can use them like how its shown above ?