2017-08-03 115 views
3

我正在研究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> 

回答

0

角不承認你的ng-modelng-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> 
+0

對此原因的解釋是什麼? Angular以某種方式模擬節點有效性? – mystrdat

相關問題