Material: mdAutoComplete should support enter key for single item

Created on 31 Mar 2015  路  2Comments  路  Source: angular/material

When autoComplete contains a single item and the enter key is selected, then the item should be auto-selected.

screen shot 2015-03-31 at 9 09 00 am

Similar to using the down-arrow, enter combinations.

enhancement

Most helpful comment

@ThomasBurleson This is supported already through the md-autoselect attribute.

All 2 comments

@ThomasBurleson This is supported already through the md-autoselect attribute.

@robertmesserle @ThomasBurleson Hello everyone, I am trying to use this in angular 4 & have a doubt that how can recognise the event after the single item is selected. i.e. I want to pass the selected item when enter key is pressed. I tried following keyup.enter but it only selects the item. the event is not triggered.

<md-autocomplete #auto="mdAutocomplete" id="autocomplete">
    <md-option *ngFor="let result of filteredResults" [value]="result.name" (keyup.enter)="navigateToView(result)" (click)="navigateToView(result)">
      <span class="row" *ngIf="result.empty">
        <span class="no-results-title" *ngIf="!result.error">Your search <span class="error-message">"{{result.userInput}}"</span> was not found</span>
        <span class="no-results-title" *ngIf="result.error">{{result.error}}</span>
      </span>
      <span class="row" *ngIf="!result.empty"> {{result.name | lowercase}}<span>&nbsp; in &nbsp;<span class="type"> {{result.type}} </span></span>
      </span>
    </md-option>
  </md-autocomplete>

any suggestion?

Was this page helpful?
0 / 5 - 0 ratings