Closed xunhuanhuan closed 8 years ago
app.controller("treeCtrl", function ($http,$scope,$log,$timeout) { var vm = this; var newId = 1; vm.ignoreChanges = false; vm.newNode = {}; $http({ url:'json/1.js', method:'GET', dataType: 'json' }).success(function(data,header,config,status){ vm.originalData = data; callback(); }).error(function(data,header,config,status){ }); vm.originalData = []; var callback = function() { vm.treeData = []; angular.copy(vm.originalData,vm.treeData); vm.treeConfig = { core : { multiple : false, animation: true, error : function(error) { $log.error('treeCtrl: error from js tree - ' + angular.toJson(error)); }, check_callback : true, worker : true }, version : 1, plugins : ['types','checkbox'] }; vm.addNewNode = function() { vm.treeData.push({ id : (newId++).toString(), parent : vm.newNode.parent, text : vm.newNode.text }); }; this.applyModelChanges = function() { return !vm.ignoreChanges; }; } })
Click the button can not be increased
Please reproduce in plunker so i will be able to check
I had the same issue, async loading the items from the backend. When removing the "treeConfig.version++" it works, but it doesn't update the view, as 'expected'.
I changed my html to do the following, to ensure my model data is loaded before loading the directive.
`
</div>`
I tried all the fixes provided here. Nothing seems to work except for the method above.
Please provide code that reproduce