Javascript 选择ng栅格内的所有复选框
我找到了一些JSFIDLE jquery代码,并尝试将其与我的Javascript 选择ng栅格内的所有复选框,javascript,jquery,angularjs,angularjs-directive,ng-grid,Javascript,Jquery,Angularjs,Angularjs Directive,Ng Grid,我找到了一些JSFIDLE jquery代码,并尝试将其与我的ng网格结合起来,以选中网格中的所有复选框。然而,它不起作用 下面是我尝试做的一个快速模型: 这是我的指令 (function(){ var app = angular.module('provider-selectall', []); app.directive('selectAll',function(){ return{ restrict: 'A', li
ng网格
结合起来,以选中网格中的所有复选框。然而,它不起作用
下面是我尝试做的一个快速模型:
这是我的指令
(function(){
var app = angular.module('provider-selectall', []);
app.directive('selectAll',function(){
return{
restrict: 'A',
link: function(scope,element,attr){
element.click(function() {
$('.ngSelectionCheckbox input[type="checkbox"]').prop('checked', true);
});
}
};
});
})();
<div class="btn-group">
<button class="my-btn btn-info" select-all>Select All</button>
</button>
</div>
将由指令激活的按钮
(function(){
var app = angular.module('provider-selectall', []);
app.directive('selectAll',function(){
return{
restrict: 'A',
link: function(scope,element,attr){
element.click(function() {
$('.ngSelectionCheckbox input[type="checkbox"]').prop('checked', true);
});
}
};
});
})();
<div class="btn-group">
<button class="my-btn btn-info" select-all>Select All</button>
</button>
</div>
试试这个
$('.ngSelectionCell.ng-scope input[type="checkbox"]').prop('checked', true);
您需要使用:
$('.ngViewport.ng-scope input[type="checkbox"]').prop('checked', true);
actulay btn group不是任何输入类型复选框的父项。但i sseen.ng作用域包含所有复选框。我建议您查看呈现的dom。@MilindantWar您查看了我的答案了吗。现在我更新了。。再次,您必须查看呈现的dom元素。我认为它与您的postcan相比是好的。您可以解释它是什么样子的吗?因为所有复选框都是在单个父div中呈现的。所有这些div都包装在另一个div中,class
ngViewport
和ng scope
在哪里可以找到它们的文档这是什么的文档??由于选择器不正确,它无法工作。我仍然不清楚您是如何看到复选框被包装在divs ngViewport和ng scope中的