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

feat(typeahead): typeahead list span entire length of input #190

Open
vision10 opened this issue Feb 15, 2016 · 1 comment
Open

feat(typeahead): typeahead list span entire length of input #190

vision10 opened this issue Feb 15, 2016 · 1 comment

Comments

@vision10
Copy link

Typeahead list or results should span the entire length of input.
If this is the way it was thought out, could you add a feature enabling this kind of behavior with a global setting or on each input?

@jsshandle
Copy link

The following workaround helps to achieve the desired behavior in the current version.

  1. Reference the input element inside the component:
export class MyComponent {

  @ViewChild('input')
  inputRef: ElementRef;

  options = ['A1', 'B2', 'C3'];

  value = '';
}
  1. Use the clientWidth property of this element to influence the width of the result list:
<input
    #input
    [(ngModel)]="value"
    [typeahead]="options"
    [typeaheadItemTemplate]="itemTemplate"
    class="form-control">

<ng-template #itemTemplate let-model="item" let-index="index">
  <div [style.width.px]="inputRef.nativeElement.clientWidth - 40">{{model}}</div>
</ng-template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
typeahead v2
  
To do
Development

No branches or pull requests

5 participants