javascript – 如何在Angular2中传递楼上的参数

我必须将参数传递给函数.

<select class="chooseWatchlist" (change)="updateWatchlistTable(item.name)">
   <option *ngFor="let item of _items">{{ item.name }}</option>
</select>

这对我来说非常重要,因为我必须将该item.name参数传递给http请求.但不幸的是,角度没有看到那个变量,因为它有点在楼下……该函数必须在选择框中取实际选择的选项的item.name.该功能将在该框中的每个值更改时执行.

有没有解决方案来解决它?或许还有另一种方法可以解决它?

最后,http请求:

private updateWatchlistTable(name) {
  this.http.get('http://localhost:8080/api/points/getValue/' + name)
   .subscribe(res => this._watchlistElements = res.json());
  console.log(name);
}

console.log(name)返回undefined.

正如您所看到的,我需要使用参数item.name来使此http请求正常工作.任何帮助赞赏.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐