typeahead not working with objects
When using an array of objects typeahead doesn't fill input field on select. This is an ugly fix:
scope.select = function (activeIdx) {
//called from within the $digest() cycle
var locals = {};
var model,
item,
first;
if (typeof scope.matches[activeIdx].model === "object"){
for (first in scope.matches[activeIdx].model) {
break;
}
locals[parserResult.itemName] = item = scope.matches[activeIdx].model[first]
} else {
locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
}
model = parserResult.modelMapper(originalScope, locals);
$setModelValue(originalScope, model);
modelCtrl.$setValidity('editable', true);
onSelectCallback(originalScope, {
$item: item,
$model: model,
$label: parserResult.viewMapper(originalScope, locals)
});
resetMatches();
//return focus to the input element if a mach was selected via a mouse click event
element[0].focus();
};
@Grigorius you should start with a reproduce scenario, instead of dumping "ugly fix" in the issue content. I'm afraid that I can't do anything with it until you provide a minimal reproduce scenario using http://plnkr.co/
Sorry about that ... here is a plunk: http://plnkr.co/edit/F9uhj7NhM7bVuPbqdh22
When selecting a country - the input field becomes [object Object], it would be nice if it took the value of the first key and display that instead? or I might be missing something obvious :)
You are missing something obvious :-) One of the possible solutions: http://plnkr.co/edit/70SUf7OEfJzZp4xM1rMq?p=preview
Btw, talking about "first key" doesn't make much sense in case of objects as you don't have any guarantee in JavaScript regarding keys order in objects.
Thank you!