angularangular-tree-component

Use of 'treeNodeFullTemplate' of angular-tree-component not clear


I'm trying to use the #treeNodeFullTemplate in my app in order to fully customize the component, but I don't seem to be able to view my datas after copying the new template described in here.

My datas don't have the name property, so I want to display the label of each node using another property, but I'm failing at that.

I tried to combine this new template with the previous ones (#treeNodeTemplate and #loadingTemplate), but nothing seems to work, and reading the docs isn't really helping me right now.

How can I tell the component to look for the property otherName instead of name?

I made an example on stackblitz.


Solution

  • You need to set options for your name property as ohterName. Read more about features of ITreeOptions here:

    import { TREE_ACTIONS, KEYS, IActionMapping, ITreeOptions } from 'angular-tree-component';
    
    options: ITreeOptions = {
        allowDrag: (node) => {
          return true;
        },
        displayField: 'ohterName',
        allowDrop: (node) => {
          return true;
        },
      };
    

    A work stackblitz example.