HTML CODE:
l = Logger.new(STDOUT)
l.info 'my log'
我想从树视图中获取已检查的项目,并将其保存为字符串','使用get函数$ scope.getCheckedItems = function(){}
在两个文本之间答案 0 :(得分:1)
您的问题不是很明确,但如果您想获得控制器内所有选中的复选框,您可以执行以下操作。
$scope.getCheckedItems = function () {
var data = $scope.tree.dataSource._data;
for (var i = 0, j = data.length; i < j; i++) {
if (data[i].checked) {
//Item is checked
//You can get the properties using data[i]
console.log(data[i]);
}
}
};
答案 1 :(得分:0)
我发现我需要指定&#39;项目&#39;作为孩子。这是工作代码:
for (var i = 0, j = data.length; i < j; i++) {
for (var x = 0, y = data[i].items.length; x < y; x++)
{
if (data[i].items[x].checked) {
//Item is checked
//You can get the properties using data[i]
console.log(data[i].items[x].text);
}
}
}
示例数据:
dataSource: [
{ text: "foo", expanded: true, items: [
{ text: "bar" }
] },
{ text: "baz", expanded: true, items: [
{ text: "qux" }
] }]