You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I did my best to understand your code and found that the 'taListItemField' option doesn't handle nested objects like {a: {b: 'foo'}} and can't reach 'b' on 'a.b' path.
I found that in your /src/services/ngx-typeahead.utils.ts:109 line could be replaced from
newItem = fields.reduce((acc, cur) => `${acc}${item[cur]}`, '');
to
newItem = fields.reduce((acc, cur) => `${acc}${cur.split('.').reduce((prev, elem)=>{return prev ? prev[elem] : prev;},item)}`, '');
and this would handle nested object fields.
I would do a pull request, but I have never done it before, that's why I'm writing here. I apologize for my inability and thank you in advance for your help.
Sidenote: did you consider that taListItemField=['a','b'], object {a: 'foo', b: 'bar'} and search 'ob' can give a false positive since you string concat all fields (in this case into 'foobar')? I know that putting a space between fields doesn't eliminate all false positives but it might reduce the numbers.
The text was updated successfully, but these errors were encountered:
Hi!
I did my best to understand your code and found that the 'taListItemField' option doesn't handle nested objects like
{a: {b: 'foo'}}
and can't reach'b'
on'a.b'
path.I found that in your /src/services/ngx-typeahead.utils.ts:109 line could be replaced from
newItem = fields.reduce((acc, cur) => `${acc}${item[cur]}`, '');
to
newItem = fields.reduce((acc, cur) => `${acc}${cur.split('.').reduce((prev, elem)=>{return prev ? prev[elem] : prev;},item)}`, '');
and this would handle nested object fields.
I would do a pull request, but I have never done it before, that's why I'm writing here. I apologize for my inability and thank you in advance for your help.
Sidenote: did you consider that
taListItemField=['a','b']
, object{a: 'foo', b: 'bar'}
and search'ob'
can give a false positive since you string concat all fields (in this case into'foobar'
)? I know that putting a space between fields doesn't eliminate all false positives but it might reduce the numbers.The text was updated successfully, but these errors were encountered: