I'm currently enhancing my ui.bootstrap typeahead with some exciting features, but I've come across a challenge that I need help with.
To better illustrate the issue I'm facing, I have put together a small Plunker example:
http://plnkr.co/edit/u2Le37?p=preview
Here's a brief overview of the problem:
I have an array of objects populating my $scope.data
, but I am struggling to instruct the typeahead
to only search using a specific field for results.
$scope.data = [
{
name: 'Mario',
desc: 'Super Plumber',
id: 0,
type: 'good'
},
{
name: 'Luigi',
desc: 'Assistant Plumber',
id: 1,
type: 'good'
},
...
When performing a search in the typeahead, it searches through every field in the object, including type
and id
.
I have attempted various solutions without success, such as:
typeahead="datum.name as ( datum.name +', '+ datum.desc)
for datum in data | filter:$viewValue | limitTo:8"
---> no change
typeahead="datum as ( datum.name +', '+ datum.desc)
for datum.name in data | filter:$viewValue | limitTo:8"
--> no match
How can I narrow down the search to, let's say, just the name
field?