ua_boaz ua_boaz - 9 months ago 101
AngularJS Question

ivh tree - disable node for selection

I am new to ivh tree ( and using this library. I want to disable to certain nodes for selection, based on user entitlement

for example i have tree like this

$scope.bag = [{
label: 'Glasses',
value: 'glasses',
entitled: false,
children: [{
label: 'Top Hat',
value: 'top_hat',
entitled: true
}, {
label: 'Curly Mustache',
value: 'mustachio',
entitled: false

So based on variable entitled: [boolean], it should let user select or unselect. how can this be done?


To accomplish this you'll need to put some logic into a custom node template. Here's a stripped down example where I've introduced a helper directive that just inspects the node scope value and disables its checkbox if needed.,js,output

app.directive('isCbEnabled', function() {
  return {
    link: function(scope, element, attrs) {
      if(scope.node.disabled) {
        element.find('input').attr('disabled', true);

You'd could attach something like this to your the ivh-treeview-checkbox directive in your template. Note that node is a supported scope variable within templates.