0
*這裏是html代碼我想獲取來自數據庫的複選框值,但我的複選框未選中任何值,只有複選框顯示,但沒有選擇任何值。 ...我的複選框沒有在angularjs中選擇任何框
ng-controller="noduesaccountsmodalcontroller" ng-init="init()">
<form name="accounts" ng-submit=submit(accounts) novalidate>
<table class="table">
<thead>
<tr>
<th>item</th>
<th>received</th>
</tr>
</thead>
<tbody ng-repeat="emp in nodueaccountassets">
<tr>
<td>{{emp}}</td> <td> <input type="checkbox" ng-model="emp.selected" value="{{emp.name}}"/></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{{albumNameArray}}
<!-- <input type="checkbox" value="{{emp}}" ng-model="checked" ng-init="checked=true"{{emp}}><br /> -->
<button type="submit" value="submit" class="btn btn-primary">ACCEPT</button>
<button class="btn btn-warning" ng-click="popup.$rollbackViewValue();">REJECT</button>
JS控制器代碼爲
application.controller('noduesaccountsmodalcontroller',function ($scope,$http,$window,$modal,$filter)
$scope.nodueaccountassets=data.list;
/*alert($scope.nodueaccountassets)*/
})
})
$scope.submit=function(form){
$scope.albumNameArray = [];
angular.forEach($scope.nodueaccountassets,function(emp){
if (emp.selected) $scope.albumNameArray.push(emp.name);
alert(emp.selected);
/*$scope.albumNameArray = $scope.nodueaccountassets.filter(function(emp){
return emp.selected;
alert(emp.selected);*/
})
/*var emp_data='emp_assets='+$scope.nodueaccountassets+'&accounts_comments='+$scope.empcomments+'&emp_code='+$scope.emplycode;
alert("data is"+emp_data)
$http.get(domain+'/insertaccountassets?'+emp_data)
.success(function(data, status, headers, config){
alert('submit successfully');
})
.error(function(data, status, headers, config){
alert(data);
})
alert("error while submitting")
}
$scope.reject=function(form)
{
$modal.dismiss('reject');
var emp_data='accounts_comments='+$scope.empcomments+'& emp_code='+$scope.emplycode;
alert(emp_data)
$http.get(domain+'/insertaccountassets?'+emp_data)
}*/
}
});
你解決了嗎? –
nop我的問題是這個項目是基於春天MVC的角度複選框值是動態值,但我的複選框沒有選擇任何框意味着不選擇甚至任何框和數據綁定 –