Tom*_*Tom 5 list typescript angular
我正在一个页面上工作,我需要一个带有搜索字段的选择框,所以我决定使用该ngSelect
模块。
我的 HTML:
<ng-select [items]="mesurePoints"
bindLabel="name"
bindValue="id"
>
</ng-select>
Run Code Online (Sandbox Code Playgroud)
mesurePoints
一些更改后,选择列表未链接到值。
小智 5
this.mesurePoints = [...this.mesurePoints]
Run Code Online (Sandbox Code Playgroud)
它将更新您的项目https://github.com/ng-select/ng-select#change-detection
小智 -8
您可以简单地使用 htmlselect
标签
请看下面的代码
<select [(ngModel)]="myvar">
<option *ngFor="let var of listOfVars" [value]="var">{{var}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
在哪里 :
myvar是将包含所选值的变量(应在打字稿组件上声明)。
listOfVars是包含变量列表的列表,在您的情况下它是mesurePoints。
归档时间: |
|
查看次数: |
3428 次 |
最近记录: |