所以下面的代码是在Angular 4中,我无法弄清楚为什么它没有像预期的那样工作.
这是我的处理程序的片段:
onUpdatingServerName(event: Event) {
console.log(event);
this.newserverName = event.target.value; //this wont work
}
Run Code Online (Sandbox Code Playgroud)
HTML元素:
<input type="text" class="form-control" (input)="onUpdatingServerName($event)">
Run Code Online (Sandbox Code Playgroud)
代码给了我错误:
'EventTarget'类型中不存在属性'value'.
但正如可以看出console.log,价值确实存在于event.target.