ng-change没有调用该方法,也没有显示错误
问题描述:
我正在研究angularjs应用程序。我有一个单选按钮,基于单选按钮的选择,我需要显示结果。 问题是当我更改单选按钮时,它不调用js代码。无法跟踪错误/问题,并且控制台上未显示任何错误。 下面我分享了整个代码,任何建议都会有帮助。ng-change没有调用该方法,也没有显示错误
HTML:
<table>
<tr>
One <input type="radio" ng-model="value" value="foo" ng-change='newValue(value)'> <br>
Two: <input type="radio" ng-model="value" value="bar" ng-change='newValue(value)'>
</tr>
</table>
答
角不承认你的ng-model
或ng-change
因为你<tr>
不包含任何<td>
。只需将您的inputs
换成<td>
即可:
<tr>
<td>
ALL <input type="radio" ng-model="value" value="foo" ng-change='newValue(value)'> <br>
Laptop,desktop,server: <input type="radio" ng-model="value" value="bar" ng-change='newValue(value)'>
</td>
</tr>
对此原因的解释是什么? Angular以某种方式模拟节点有效性? – mystrdat