Skip to content

Instantly share code, notes, and snippets.

@guilbep
Created June 13, 2014 13:21
Show Gist options
  • Save guilbep/35e8a4781d6be2b666a2 to your computer and use it in GitHub Desktop.
Save guilbep/35e8a4781d6be2b666a2 to your computer and use it in GitHub Desktop.
module.filter('cutTree', [
function() {
return function(tree) {
var res = [];
var i = 0;
angular.forEach(tree, function(tree1) {
var level1 = {};
var level2 = [];
angular.forEach(tree.children, function(tree2) {
var level3 = {};
var level4 = [];
angular.forEach(tree2.children, function(tree3) {
var level5 = {};
var level6 = [];
})
level3.id = tree1.id;
level3.sort_order = i;
level3.children = level4;
i++;
level2.push(level3);
})
level1.id = tree1.id;
level1.sort_order = i;
level1.children = level2;
i++;
res.push(level1);
})
return res;
};
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment