ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 101 forks source link

ReloadTree from the DataBase once Updated Data into server #115

Open smohammedyasin opened 7 years ago

smohammedyasin commented 7 years ago

Hello,

i have used vm.treeConfig.version++ . and i can see in the log that tree version is increasing but tree not reloading.

app.controller('treeCtrl')// Controller For Tree
{
         var vm = this;
        vm.ignoreChanges = false;
        vm.treeData = [];//

        $scope.getTreeData = function () {
            var getData = channelServices.getTree();
            getData.then(function (chn) {
                //console.log(chn.data);
                for (var i = 0; i < chn.data.length; i++) {
                    vm.treeData.push({
                        id: chn.data[i].id, parent: chn.data[i].parent, text: chn.data[i].text,
                        type: chn.data[i].type, state: { checkbox_disabled: chn.data[i].checkboxdisabled, opened: 
                         chn.data[i].opened, disabled: chn.data[i].disabled }, image: 'yasin'
                    })
               }
              scope. reloadTree();
            }, function (chn) {
                toastr.error(chn.data, 'Oh My!');
            });
        };

       vm.treeConfig ={......}//config for tree

    $scope.reloadTree = function () {//reload tree
            vm.treeConfig.version++;
            console.log(vm.treeConfig.version);
        };
}

app.cotroller('modelCtrl')//model popup controller
{
      $scope.UpdateNode=function(){
    //update into server using http$
             $scope.$parent..reloadTree();
       };
}

each time when i call function "UpdateNode" from modal popup can see tree version is increasing but tree not recreating with updated data from the server