ludo / jquery-treetable

jQuery plugin to show a tree structure in a table
http://ludo.cubicphuse.nl/jquery-treetable
GNU General Public License v2.0
741 stars 278 forks source link

Problem building the treetable dynamically with an angular directive #194

Open dgodwin1175 opened 7 years ago

dgodwin1175 commented 7 years ago

Hi, Not sure if anyone has had any experience working with this component in angular?
I'm building up the rows of the table dynamically inside an angular directive, which works great. The trouble I have is handling the ng-click events on links in the rows, where those ng-click attributes point to functions in my controller.

E.g. the HTML looks like this (excuse the lack of angle brackets, they don't appear to be allowed): table ch-tree-table class="treeTable" ng-model="myCtrl.myData" ng-expandable="true" thead tbody/ /table

My directive is doing this sort of thing: var node = $(elements).treetable("node", i + 1); var html = "tr class='rowHeader' data-tt-branch='true' data-tt-id='1'" + "td" + "a href='#' ng-click='myCtrl.clickHandler()'>Click me /a" + "/td" + "/tr"; var locationLinkFn = this.$compile(html); var content = locationLinkFn(scope); $(elements).treetable("loadBranch", node, content);

While the table renders as expected, clicking on the 'Click me' link does not call my clickHander() function.

Any suggestions on how to achieve this? Thanks.