angular 不会显示作用域变量(完成)

angular won't display scope variable (done)

我正在使用 jstree 和 angularjs。我有节点的路径和名称,但无法在页面上显示。我的错误在哪里?我已经用 ng-tree 指令更新了 plunker(working) 示例以解决我的问题。现在它离我的应用程序很近了

我这里也提供plunker的代码

Html:

 <h1>Where is my variable?!</h1>
         <div>{{ test }}</div>
  <pre>Path to A: {{ pathA }}</pre>
   <pre>Path to B: {{ pathB }}</pre>
      <pre>Path to C:{{ pathC }}</pre>
<js-tree tree-data="json" tree-src="tree.json"
                   tree-events="changed:callback;"></js-tree>

Js

$scope.test = "I'm test variable"

    $scope.callback = function (e, data) {

        // ===== Click event on node for Industry =====
        for (var i = 0; i < data.selected.length; i++) {

            var parentNodeId = data.instance.get_node(data.selected[i]).parent;
            var parentNodeText = data.instance.get_node(parentNodeId).text;
            var selectedNodes = data.instance.get_selected();

            var node = data.instance.get_node(data.selected[i]).text;

            console.log(node);

            if (node == "a"){
                     console.log($scope.pathA)
             $scope.pathA  = data.instance.get_path(data.node,'/');

            }
             else if (node == "b"){
                 console.log($scope.pathA)
              $scope.pathB  = data.instance.get_path(data.node,'/');

            }
             else if (node == "c"){
               console.log($scope.pathA)
             $scope.pathC  = data.instance.get_path(data.node,'/');

            }
            // and etc....
        }
    }

您的 jstree 不会引起任何变化检测,这意味着回调也不会,您的 none 变量将得到更新。您可以通过在回调中手动调用 $scope.$apply() 来解决此问题!