I want to show Parent Children graphical representation on Angular Material Flat Tree.
This is the design :
Here is the DEMO what i done so far.
I want to show Parent Children graphical representation on Angular Material Flat Tree.
This is the design :
Here is the DEMO what i done so far.

FIRST SOLUTION
here is the stackBlitz Demo
here is the stackBlitz editable link
I've made a recursive call on every visible node reffering to the node index using
treeControl.dataNodes.indexOf(node)here is the recursive function:
this returns an array of
truefalsevalues for your[ngClass]then in html I call that function as so
and finally I've created another class in the css called
node-arrow-emptywithout bordersdepending on weither the value in the array is
trueorfalseit switches in the html between the two classes.SECOND SOLUTION
stackBlitz DEMO
stackBlitz editable link
the other solution would be to keep track of last element in array by adding for example a
isLast:booleanproperty. Of course if the datas you are dealing with are dynamic you need to find a way to dinamically change that value.Once the
isLastis filled you make a recursive call which will find the previous sibling withcurrent node level - 1. That being said you will check 2 things. First thing is, is the node classes containsn-last(which is the class name I gave to Html representing last element of parent array) and second thing retrieve the classn-{{node-level}}.By recursively (you can make a non recursive method if you wan't to) retrieving the
previousElementSiblingwhich has classn-3orn-2... ton-0you can check if each of this element contains an-lastclass. You push thetrueorfalseinto an array and just as the first solution switch between classnode-arrowandnode-arrow-empty.here is the recursive function
the HTML (here is only parent node but same thing for child)
as you can see I'm passing element to the dummy fucntion with a template variable called
#refPand here are the
PARENTNODEandCHILDNODEdeclaration:THIRD SOLUTION
I won't code it but I'll try to explain it.
This is kind of similar to the previous solution except your could parse when tree is changed (swapping, deletion, add) the data and add a property like
divTypepopulated withtrueorfalseand call it in your html as so