如何在當前值更改之前識別「單選按鈕」的值更改?angularjs:更改單選按鈕值之前的事件
在我的應用程序中,我需要提醒用戶有關更改此單選按鈕的值將導致其餘形式的影響。
我已經嘗試過使用ngChange和ngClick,但單選按鈕的值始終會更改(到新值),即使在我可以使用當前值執行某些操作之前。
例子:
<form>
<label>Nivel de gestão</label>
<input name="gestao" type="radio" data-ng-model="nivelGestao" value="T" data-ng-change="mudarNivelGestao()">Tecnica
<input name="gestao" type="radio" data-ng-model="nivelGestao" value="O" data-ng-change="mudarNivelGestao()">Operacional
<input name="gestao" type="radio" data-ng-model="nivelGestao" value="I" data-ng-change="mudarNivelGestao()">Institucional
<table>
<tr>
<td>Id</td>
<td>Nome</td>
</tr>
<tr data-ng-repeat="gestor in gestores">
<td>{{gestor.id}}</td>
<td>{{gestor.nome}}</td>
</tr>
</table>
<script>
...
$scope.mudarNivelGestao = function() {
alert($scope.nivelGestao); // In this place the content has already been changed, but before I need to alert and ask if the User want continue, if "No" return to the last value, if "Yes" change the value and go ahead...
...
}
...
</script>
</form>
'$範圍。$表( 'nivelGestao',函數(的newval,OLDVAL,ATTR){ 如果(用戶需要改變){}其他{$ scope.nivelGestao = OLDVAL}} )'你可以像這樣看待價值 – 2014-08-31 15:58:18