Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ivh-TreeView AngularJs Get Node id On Label Click #164

Closed
ghost opened this issue Oct 27, 2016 · 7 comments
Closed

ivh-TreeView AngularJs Get Node id On Label Click #164

ghost opened this issue Oct 27, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Oct 27, 2016

Im new to AngularJs and I have used Angular Ivh_treeview component for displaying a nested tree from JSON data. The Tree is loaded correctly. Now i want to

Get the Node Id On Label Click . So for a trial i tried to make an alert box so that i can check if function call works. Ivh-Treeviewe has only checkbox functions. So tried to Add a Custom Template

nodeTpl: [ '<div>', '<span ivh-treeview-toggle>', '<span ivh-treeview-twistie></span>', '</span>', '<span href="#here" class="ivh-treeview-node-label" ng-click="test()">', '{{trvw.label(node)}}', '</span>', '<div ivh-treeview-children></div>', '</div>' ].join('\n')

and on controller
this.test = function() { alert("hello"); }

Bt now the click event isnt invoked. Can some one please resolve this . Also tried to do with $scope.test definition bt it didnt worked.

@christophercr
Copy link

Hi @drvishnu,

Which version ivh-treeview are you using? In version 1 indeed there is no way to use the vars/methods in your controller/scope.

So I created a PR to solve this issue #81 and it was released in v2.0.0-alpha.2. then you can access your controller using $parent. In your case then using $parent.test() should make the trick.

@ghost
Copy link
Author

ghost commented Oct 27, 2016

update: The Demo Script :: http://jsbin.com/ropuyeg/edit?html,js,output

im using the CDN version ..
http://rawgit.com/iVantage/angular-ivh-treeview/master/dist/ivh-treeview.js

Now when i tried
ng-click="$parent.test()"

the function doesnt get invoked. tried to debug in chrome bt breakpoint isnt getting

app.controller('DemoCtrl', function($scope) {

  this.stuff = stuff1;
  this.test = function() {
    alert("hello");
  } 

@christophercr
Copy link

I see, then you need to use this instead:
http://rawgit.com/iVantage/angular-ivh-treeview/v2.0.0-alpha.2/dist/ivh-treeview.js

But I'm afraid the dist files are not updated, they are still the ones generated from v1.

@jtrussell maybe you can generate the dist files for v2?

jtrussell added a commit that referenced this issue Oct 30, 2016
@jtrussell
Copy link
Contributor

jtrussell commented Oct 30, 2016

I just updated the dist files in v2.0.0-alpha.3.

Apologies for going dark, I've been away for the past couple weeks. I'm still working through ironing out some dev dependency incompatibilities with the new version of node but at least the dist files should be there :). I'll get a new cut soon with the dev deps updated too.

@jtrussell
Copy link
Contributor

I believe this is a duplicate of this SO post. Let's continue the conversation there as needed :).

@ghost
Copy link
Author

ghost commented Nov 3, 2016

Ya it was posted on StackExchange bt none replied there and even after adding v2.0.0-alpha.3 my problem isnt solved ....

@jtrussell
Copy link
Contributor

No worries, I only closed this issue as we tend to prefer keeping usage questions on SO. I've posted an answer over there. Let me know if anything is not clear and I'd be happy to go deeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants