自动填充实现,搜索,过滤。角

时间:2018-02-01 08:49:45

标签: html angular typescript autocomplete materialize

在下面的代码中,我想使用search inside选项,比如autocomplete。我怎么能这样做?

  <div class="row">
        <div class="input-field col s12">
          <select formControlName="sensorType_id" id="sensorType_id" materialize="material_select" [materializeSelectOptions]="sensorstype">
            <option value="" disabled selected>Select Sensor Type</option>
            <option *ngFor="let sensortype of sensorstype" [value]="sensortype.sensorType_id">{{sensortype.sensordescription}}</option>
          </select>
        </div>
      </div>

1 个答案:

答案 0 :(得分:1)

你可以这样做

<div class="row">
        <div class="input-field col s12">
            <md-input-container class="full-width">
                <input mdInput placeholder="Location *" [mdAutocomplete]="autoSensore"
                       #searchLocation
                       formControlName="sensorType"
                       (keyup)="onChangeLocationName()">
            </md-input-container>
            <md-autocomplete #autoSensore="mdAutocomplete">
                <md-option
                        *ngFor="let sensortype of sensorstype | search: searchLocation.value"
                        [value]="sensortype.sensordescription"
                        (onSelectionChange)="onSelected($event.source.selected, sensortype.id)">
                    {{ location.name }}
                </md-option>
            </md-autocomplete>
        </div>
    </div>

您还需要创建搜索管道