<div class="add">
  <div class="toggle" [class.active]="ddVisible" (click)="toggleDD()">Добавить элемент</div>
  <div class="dropdown active" [class.active]="ddVisible" (mouseleave)="hideDD()">
    <div class="menu">
      <div *ngFor="let type of types" class="type">
        <div class="row" *ngIf="type?.children?.data?.length > 0; else addItem" (click)="submenu(type)">
          <div class="title">{{type.title}}</div>
          <div class="submenu{{type.showChilren?' active':''}}"></div>
        </div>
        <ng-container *ngIf="type.showChilren">
          <div class="sub-row" *ngFor="let childrenType of type?.children?.data" (click)="add(childrenType.name)" [innerText]="childrenType.title"></div>
        </ng-container>
        <ng-template #addItem>
          <div class="row" (click)="add(type.name)"><div class="title" [innerText]="type.title"></div></div>
        </ng-template>
      </div>
    </div>
  </div>
</div>
