0

I make a simple demo of jstree using angular js .I read this documentation https://github.com/ezraroi/ngJsTree before making the example

Both codepen have same JS Code .But one code pen show "folder image " and another don't why ..? http://codepen.io/anon/pen/mVRarZ?editors=101

http://codepen.io/anon/pen/JGEwPv?editors=101

if I replace second codepen JS code to first codepen js it show the folder..But I don't understand what is the difference in in JS ..why first codepen show folder and another don't

angular.module('app',['ngJsTree']).controller('myCtrl',function($scope,$log){ 
      $scope.treeConfig = {
        core : {
            multiple : false,
            animation: true,
            error : function(error) {
                $log.error('treeCtrl: error from js tree - ' + angular.toJson(error));
            },
            check_callback: true,
            worker : true
        },
        types : {
            default : {
                icon : 'glyphicon glyphicon-flash'
            },
            star : {
                icon : 'glyphicon glyphicon-star'
            },
            cloud : {
                icon : 'glyphicon glyphicon-cloud'
            }
        },
        version : 1,
        plugins : ['types','checkbox']
    };

     $scope.originalData = [
        { id : 'ajson1', parent : '#', text : 'Simple root node', state: { opened: true} },
        { id : 'ajson2', parent : '#', text : 'Root node 2', state: { opened: true} },
        { id : 'ajson3', parent : 'ajson2', text : 'Child 1', state: { opened: true} },
        { id : 'ajson4', parent : 'ajson2', text : 'Child 2' , state: { opened: true}}
    ];
    $scope.treeData = [];
    angular.copy($scope.originalData,$scope.treeData);

})

1 Answer 1

0

I recommend using a diff checker for your code. In terms of being exactly the same, your code is slightly different, albeit mostly in spacing and commenting out things. This is the tool I used for this: https://www.diffchecker.com/diff

Your DOM is obviously different as well. If you're JS code is exactly the same, then your DOM should be swappable and function the same. It is not. If I swap the DOM from the 1st link and use it for the 2nd, it doesn't function.

If you're trying to refactor your code, I'd advise you to refork your code from the 1st link and c&p in a more granular way.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.