【问题标题】:why image is not display in angular js?为什么图像不显示在 Angular js 中?
【发布时间】:2016-01-04 14:41:50
【问题描述】:

我使用 Angular js 做了一个简单的 jstree 演示。我阅读了这个文档 https://github.com/ezraroi/ngJsTree做例子之前

两个codepen都有相同的JS代码。但是一个codepen显示“文件夹图像”而另一个不显示..为什么? http://codepen.io/anon/pen/mVRarZ?editors=101

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

如果我将第二个 codepen JS 代码替换为第一个 codepen js,它会显示文件夹..但我不明白 JS 有什么区别..为什么第一个 codepen 显示文件夹而另一个不显示

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);

})

【问题讨论】:

    标签: angularjs angularjs-directive angularjs-scope angular-ui-router


    【解决方案1】:

    我建议对您的代码使用差异检查器。就完全相同而言,您的代码略有不同,尽管主要是在间距和注释方面。这是我使用的工具:https://www.diffchecker.com/diff

    您的 DOM 也明显不同。如果您的 JS 代码完全相同,那么您的 DOM 应该是可交换的并且功能相同。它不是。如果我从第一个链接交换 DOM 并将其用于第二个链接,它就不起作用。

    如果您尝试重构您的代码,我建议您从第一个链接重新分叉您的代码,并以更精细的方式 c&p。

    【讨论】:

      猜你喜欢
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-17
      • 2020-11-22
      • 2015-12-08
      • 2014-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多