【发布时间】:2016-11-16 10:22:48
【问题描述】:
我正在尝试在作为ComponentA 一部分的 HTML 输入文本框中从作为ComponentB 一部分的打字稿代码设置值。
从this 中获取线索,所以我尝试这样做:
(<HTMLInputElement>document.getElementById("name")).value = response.name;
但这不起作用。还有什么需要我照顾的吗?
编辑: ID 为 "name" 的元素在 ComponentA 中,而上面试图操作该元素的代码在 ComponentB 中
【问题讨论】:
-
有什么理由不使用ngModel,从而将输入绑定到一个变量?
标签: html angular typescript textbox