【发布时间】:2018-04-28 06:20:26
【问题描述】:
我有这个textbox 供客户搜索id:
Enter Id: <input type="text" [(ngModel)]="temp.id">
<button (click)="myEvent()">My Button</button>
<table class='table' *ngIf="collection">
<tbody>
<tr *ngFor="let item of collection">
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
</tr>
</tbody>
在myEvent方法中,我不知道我应该如何获取给定Id的相关绑定对象,以便我得到它的name属性并将其发送到我的WEB API:
temp: any = { id: '' };
myEvent() {
this.http.get('url', {
params: {
id: this.temp.id,
name: ???
}
})
}
【问题讨论】:
-
在你的 *ngFor 循环中吗?
-
@RukshanDangalla 不。正如我在更新的问题中显示的那样,它不在表格之外。
-
@RukshanDangalla 如果解决方案是将我的按钮放在 *ngFor 循环中,我将更改我的代码。请告诉我我该怎么做?
标签: c# angular asp.net-web-api asp.net-core-mvc