Using Angular 6, how could you fill in the total field that represents the total number of direct and indirect bosses of each employee?
I have the following data:
const employees = [
{
id: 1,
firstName: 'a',
lastName: 'A',
position: 'PA',
chefes: [2, 3],
compensation: '123.00'
},
{
id: 2,
firstName: 'b',
lastName: 'B',
position: 'PB',
chefes: [4],
compensation: '456.00'
},
{
id: 3,
firstName: 'c',
lastName: 'C',
position: 'PC',
compensation: '789.00'
},
{
id: 4,
firstName: 'd',
lastName: 'D',
position: 'PD',
compensation: '1011.00'
}
];
return {employees};
In the above example, employee A has as direct boss employee B and C. But employee B has direct boss D. Employee D. In addition to direct + indirect bosses the employee has 2 + 1 = 3 bosses the employee B = 1 and employees C and D have 0 bosses.
This would be the part of the html that generates the total nuero of bosses (direct + indirect):
<dl>
<dt>Título</dt>
<dd>{{employee.position}}</dd>
<dt>Compensation</dt>
<dd>${{employee.compensation}}</dd>
<dt>Total</dt>
<dd>${{total????}}</dd>
</dl>