1
我有这张桌子的角度,我发送她的数据,它显示它,加深了数据。我还添加了我想要的cheackbox输入,当我点击它时,他标记了所有的复选框,但他不能很好地工作。如何在自定义表中标记AngularJs中的所有复选框?
这里是角的指令:
app.directive("tables", function(){
return {
template: '<table class="table table-striped table-bordered table-hover">'+
'<thead>'+
'<tr>'+
'<th>#</th>'+
'<th><input type="checkbox" ng-model="selectAll" ng-click="checkAll(values)" /></th>'+
'<th ng-repeat="(key,label) in labels">'+
'<a href="" ng-click="orderByField=key; reverseSort = !reverseSort">'+
'{{ label }} '+
'<span ng-show="orderByField == key" class="sortIcon">'+
'<span ng-show="reverseSort">'+
'<span class="glyphicon glyphicon-chevron-up"></span>'+
'</span>'+
'<span ng-show="!reverseSort">'+
'<span class="glyphicon glyphicon-chevron-down"></span>'+
'</span>'+
'</span>'+
'</a>'+
'</th>'+
'</tr>'+
'</thead>'+
'<tbody>'+
'<tr ng-repeat="(what,items) in values | orderBy:orderByField:reverseSort | filter :searchInput " >'+
'<td>{{ $index +1 }}</td>'+
'<td> <input type="checkbox" ng-model="user.select" value="{{ items[fieldId] }}"></td>'+
'<td ng-repeat="(key,item) in items" ng-if="item != items[fieldId] ">{{item}}</td>'+
'</tr>'+
'</tbody>'+
'</table>',
link: function($scope) {
$scope.checkAll = function(arraySelect) {
angular.forEach(arraySelect, function(user) {
user.select = $scope.selectAll;
});
};
}
}
});
以下是完整的例子:jsFiddle
它工作的感谢! – oded