[英]How to highlight the option selected in <ng-select> and <ng-option> tag in angular 5
我有2個標簽,當我單擊下拉面板時,它會提供各種選項供選擇,默認情況下會選擇一個值,但是當我打開下拉面板時,它不會突出顯示先前選擇的選項。
我嘗試在<ng-option>
標記中添加[selected]="filters"
或[ng-selected]="filters"
,但這給了我一個錯誤,因為它不是<ng-option>
的已知屬性
如何突出顯示在下拉面板中選擇的此選項?
<ng-select [(ngModel)]="filterSelected" name="in" id="fileterName"
(open)=droppanel() >
<ng-option *ngFor="let opt of filterJSONData" [value]="opt.val" >
{{ opt.content }}
</ng-option>
</ng-select>
提前致謝。
選擇的定義應如下所示:
<ng-select
[items]="filterJSONData"
bindLabel="{{content}}" bindValue="{{val}}"
[(ngModel)]="filterSelected">
<ng-template ng-option-tmp let-item="item" let-search="searchTerm">
<div [ngOptionHighlight]="search">{{ item.content }}</div>
</ng-template>
</ng-select>
在選擇中鍵入文本時,匹配值顯示為下划線。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.