如何在输入字段上添加$ watcher?

时间:2016-06-07 06:14:34

标签: javascript jquery html angularjs

记住ng-change,我想看看如何为输入字段编写基本的监视功能。

如何将手表应用于以下输入字段作为示例?

<span class="dropdown-text">
    Col <input type="text" value='tiledata.col' ng-model="tiledata.col" class="input-col" id="aeS-Col" ng-click="vm.setInputCol()">
    Row <input type="text" value='tiledata.row' ng-model="tiledata.row" class="input-row" id="aeS-Row" ng-click="vm.setInputRow()">     
    <i class= "fa fa-arrows"></i>
</span> 

1 个答案:

答案 0 :(得分:1)

那么你有2个输入字段。这对你有用吗?

$scope.$watch('tiledata.col', function(newValue, oldValue) {
    alert('The new value of the input is ' + newValue);
});
相关问题