这是我的第一个带有javascript代码的html文本框
print(count)
这是我的第二个html标签
<div>
<input type="text" onchange="getTheValue(this)" id="12345" />
</div>
在<input type="hidden" id="12345_hiddenField" ng-model="hiddenField"/>
事件中,我正在调用此javascript函数
onchange
我希望将第一个文本框值分配给第二个文本框function getTheValue(data) {
document.getElementById("12345_hiddenField").value = data.value;
}
值,使用纯javascript no angualrjs方法,becoz ngmodel
函数是用单独的纯javascript文件编写的,是他们无论如何要做的这个?
答案 0 :(得分:1)
我会这样做。
document.getElementById("12345").addEventListener('change',function() {
document.getElementById("12345_hiddenField").value = document.getElementById("12345").value;
答案 1 :(得分:0)
<input type="text" ng-model="textboxValue" id="12345" />
和你隐藏的:
<input type="hidden" id="12345_hiddenField" value="{{textboxValue}}"/>
您的输入文字已绑定到$scope
属性textboxValue
您的隐藏输入将该变量用作值{{textboxValue}}
,一切都是双向数据绑定。