Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.tree = Tree.parentize({
- title: 'root',
- children: [{
- title: 'child one',
- children: [{
- title: 'leaf one',
- children: []
- }, {
- title: 'leaf two',
- children: []
- }, {
- title: 'leaf three',
- children: []
- }]
- }, {
- title: 'child two',
- children: [{
- title: 'leaf four',
- children: []
- }, {
- title: 'leaf five',
- children: []
- }]
- }]
- });
- 'use strict';
- var Tree = (function () {
- var parentize = function(tree) {
- angular.forEach(tree.children, function(value, key) {
- this.children[key].parent = function() {
- return tree;
- };
- parentize(value);
- }, tree);
- return tree;
- };
- return {
- parentize: parentize
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement