gpt4 book ai didi

Angular Material 2 - 自动完成中的自定义 mat-option/md-option 模板

转载 作者:太空狗 更新时间:2023-10-29 17:26:37 26 4
gpt4 key购买 nike

Angular Material 2 是否有选择器来自定义自动完成选项,例如 AngularJS 的 Angular Material md-item-template?我在 docs 上找不到任何东西来自 Material 2

来自 docs 的 AngularJS 示例:

<md-autocomplete
<md-item-template>
<span class="item-title">
<md-icon md-svg-icon="img/icons/octicon-repo.svg"></md-icon>
<span> {{item.name}} </span>
</span>
<span class="item-metadata">
<span class="item-metastat">
<strong>{{item.watchers}}</strong> watchers
</span>
<span class="item-metastat">
<strong>{{item.forks}}</strong> forks
</span>
</span>
</md-item-template>
</md-autocomplete>

enter image description here

最佳答案

两行mat-带图片自动补全的解决方案

<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="State" aria-label="State" [matAutocomplete]="auto" [formControl]="stateCtrl">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let state of filteredStates | async" [value]="state.name">
<img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="20" />
<span>{{ state.name }}</span> <br>
<small>Population: {{state.population}}</small>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
// CSS
.mat-option {
height: 50px;
line-height: 20px;
}

关于Angular Material 2 - 自动完成中的自定义 mat-option/md-option 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46530305/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com