我是角度js中的新角色。當我點擊該複選框時,我有一個複選框會出現確認消息。只有當我確認確認信息時,我才需要選中或取消選中複選框。我怎樣才能做到這一點與角js。(目前複選框是檢查/取消選中,即使我取消確認消息)。這是我的複選框元素。只有當確認消息在角度js中爲真時,才選中/取消選中複選框
<input type="checkbox"
ng-init="checkValue = x.status"
ng-model="checkValue"
ng-true-value="1"
ng-false-value="0"
ng-checked="x.status == 1"
ng-click="changeStatus(<% x.id %>, 1, checkValue)">
,這是我的js部分
$scope.changeStatus = function(id, iFlag, checkValue) {
var confrm = confirm('Are you sure that you want to do this');
if (confrm) {
Data.post('url', param)
.then(function(data){
if (data.success == 1)
AlertService.setSuccess('Status changed successfully!');
else
AlertService.setError('Some error occured. Please try again');
})
}}
修改changeStatus函數中的x.status值。 – SaiUnique