以下是我的代码
<form class="form-horizontal" name="addForm.REFForm" role="form" ng-submit="saveInfo(currentPlayer.Player,playerinfo.StateLevel)" novalidate>
<div class="btn-group" data-toggle="buttons">
<label class="btn btnProfileDefault" ng-class="{'true':'active', 'false':''}[playerinfo.StateLevel]">
<input type="radio" value="true" name="StateLevel" ng-model="playerinfo.StateLevel">
Yes
</label>
<label class="btn btnProfileDefault" ng-class="{'true':'', 'false':'active'}[playerinfo.StateLevel]">
<input type="radio" value ="false" name="StateLevel" ng-model="playerinfo.StateLevel">
No
</label>
</div>
</form>
如果有人点击是,我想将playerinfo.StateLevel
的更新值发送到SaveInfo
功能,但我无法执行此操作playerinfo.StateLevel
值未更新数据切换是否存在无论如何。
答案 0 :(得分:0)
因为当您单击是或否时,saveInfo()
中的ng-submit
功能将无法触发。您应该添加如下所示的ng-change或添加提交按钮。
<div class="btn-group" data-toggle="buttons">
<label class="btn btnProfileDefault" ng-class="{'true':'active', 'false':''}[playerinfo.StateLevel]">
<input type="radio" value="true" name="StateLevel" ng-model="playerinfo.StateLevel" ng-change="clicked(currentPlayer.Player, playerinfo.StateLevel)"> Yes
</label>
<label class="btn btnProfileDefault" ng-class="{'true':'', 'false':'active'}[playerinfo.StateLevel]">
<input type="radio" value="false" name="StateLevel" ng-model="playerinfo.StateLevel" ng-change="clicked(currentPlayer.Player, playerinfo.StateLevel)"> No
</label>
</div>