Error: $scope.treeInstance is undefined
See original GitHub issueI’m using AngularJS 1.4.2 and jQuery 2.1.4
my controller:
angular.module('app.controller', [
'ngJsTree'
]).controller('AppController', function ($scope, $log) {
//...
var selected_nodes = $scope.treeInstance.jstree(true).get_selected();
}
my template:
<div js-tree="treeConfig" ng-model="treeData" tree="treeInstance">
and got: Error: $scope.treeInstance is undefined
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
how to get tree instance in controller - Ext 4
I have a small problem to get the instance of my tree in controller. Well, without the MVC pattern it looks like this...
Read more >TreeInstance - Scripting API
Contains information about a tree placed in the Terrain game object. This struct can be accessed from the TerrainData Object. Properties. color, Color...
Read more >Tigra Tree Menu PRO
Key Description Accepted Values Default Value
icon_48 Icon for a root path to the image icons/base.gif
alt_48 Icon for a root alt and title attribute...
Read more >mstform README
You can modify the mobx-state-tree instance in code as well and the form is automatically updated. ... error : An error message (or...
Read more >CLI Reference Guide Version 6.7
Interface Error Disable and Auto Recovery Commands 550 ... ipv6 nd ra hop-limit unspecified . ... Adds an administrative scope multicast boundary.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the solution, the problem is to use treeInstance direct to the $scope as:
<div id="myTreeId" js-tree="treeConfig" ng-model="treeData" tree="treeInstance">
You have to initialize an object in the controller, for example:
After this, use the model in your template as:
<div id="myTreeId" js-tree="treeConfig" ng-model="treeData" tree="model.treeInstance">
And in the controller:
$scope.model.treeInstance
, won’t be undefined.@melino you must wait for the ready event of the jsTree before using the api instance. In the controller constructor it will not be available