Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(typeahead): Please support nested property in typeaheadOptionField if possible #135

Closed
hongbo-miao opened this issue Feb 3, 2016 · 1 comment · Fixed by #777
Closed

Comments

@hongbo-miao
Copy link
Contributor

I am trying to use Typeahead.

The example code

private statesComplex:Array<any> = [
    {id: 1, name: 'Alabama'}, {id: 2, name: 'Alaska'}, {id: 3, name: 'Arizona'}];

and

<input [(ngModel)]="selected"
       [typeahead]="statesComplex"
       (typeaheadOnSelect)="typeaheadOnSelect($event)"
       [typeaheadOptionField]="'name'"
       class="form-control">

runs well.

But when I try to change the data format

private statesComplex:Array<any> = [
    {id: 1, profile: {name: 'Alabama', email: '111'}}, {id: 2, profile: {name: 'Alaska', email: '222'}}, {id: 3, profile: {name: 'Arizona', email: '333'}}];

and use

<input [(ngModel)]="selected"
       [typeahead]="statesComplex"
       (typeaheadOnSelect)="typeaheadOnSelect($event)"
       [typeaheadOptionField]="'profile.name'"
       class="form-control">

It does not work. The problem is typeaheadOptionField does not support nested property. I got the answer from here. http://stackoverflow.com/questions/35187354/typehead-in-ng2-bootstrap-cannot-show-items-in-angular-2/35187996#35187996

Please support nested property in typeaheadOptionField if possible. Thanks!

@valorkin valorkin changed the title Please support nested property in typeaheadOptionField if possible chore(typeahead): Please support nested property in typeaheadOptionField if possible Feb 6, 2016
valorkin pushed a commit that referenced this issue Jul 24, 2016
@bhaveshvyas007
Copy link

bhaveshvyas007 commented Jan 6, 2019

Can we have this feature more options ? so that I can have two attributes path to match
I am facing issue in implementing grouped json structure.

For example :
{ "Skill": [ { "SkillName": "Data Analysis", "SubSkills": [ {"SkillName": "SQL"}, {"SkillName": "RDBMS"}, {"SkillName": "Oracle"}, {"SkillName": "Postgresql"}, {"SkillName": "Sybase"}, {"SkillName": "MongoDB"}, {"SkillName": "JSON"}, {"SkillName": "XML"} ] }, { "SkillName": "Skill 2", "SubSkills": [ {"SkillName": "abc"}, {"SkillName": "xyz"}, {"SkillName": "pqr"}, ] }, ] }

In above example I am using typeaheadOptionField = SkillName. But I also need to match SkillName from subskills and return the whole skill object on select

Is it possible now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants