I have this small problem with Typeahead directive here is my code so far:
$scope.getUserNames = function (input) {
return $http.get(ApplicationConstants.apiUrl + 'api/Users/UserNames', {
headers: { 'ContentType': 'application/json' },
params: {
input: input
}
}).then(function (response) {
$log.debug('GetUserNames:', response.data);
return response.data;
}, function (error) {
$log.debug(error);
});
};
This is as required by the documentation - the promise is being returned and the contents of the response data are as follow : ['username1','username2',...]
Then in markup I have following code:
{{userNameSelected}}
<input type="text" ng-model="userNameSelected" placeholder="Type the username" typeahead="val as val for val in getUserNames($viewValue)" class="form-control">
I've tried using "val for val in getUserNames($viewValue)" but it also doesn't help. The problem is that the model gets updated correctly but no dropdown under the typeahead input is being shown - no results. Am I doing something wrong ? Just to mention I have latest angular and angular-ui-bootstrap