The ember template displays information:

{{#each model.item1 as |item1|}} {{item1.title}} {{#each item1.item2 as |item2|}} {{item2.title}} {{#each item2.item3 as |item3|}} {{item3.title}} {{/each}} {{/each}} {{/each}} 

How to make it so that if item3.title zero, then item2.title not displayed. And if item2.title zero, then item1.title should not be output. Those. if there are no children, then do not display the parent. I would understand the algorithm.

  • 2
    Well, purely schematic {each x as xx} IF NOT xx IS EMPTY {xx.title} {each xx as xxx} IF NOT xxx IS EMPTY {xxx.title} ... {/each} . And if there are IF, how to check for the absence of daughters and how it is spelled correctly - understand yourself ... - Akina

1 answer 1

It is necessary to clear the checkbox of the output, and then in a cycle for daughters to try to raise it.
If the checkbox is raised, then there are daughters, and you can withdraw.
And if it remains dumped, then there are no daughters, and no need to withdraw.

  • It would have come if mother was brought out after daughters. But she appears in front of them - what, two times to dig up daughters? - Akina
  • You can store an array of checkboxes so that each daughter will manage her own flag. If there are few daughters, then it is better to use the word - so that each daughter controls her bit, while mother checks for zero. - Yuri Negometyanov
  • This is wrong when an entity instance tries to manage the attributes of another entity instance directly. I understand, if it was proposed to the “daughter” to pull the “mother” for the method “mother, now you have me” - but the mother most likely already knows about the presence of daughters, for all of them are her attribute. By the way, it is possible that each itemX property has an itemX.subItems.Count property, which can be used instead of the IS EMPTY test I proposed above, comparing with zero. - Akina
  • If so, then there is nothing to make a garden too - Yuri Negometyanov