K
K
Konstantin2020-03-05 18:04:31
Angular
Konstantin, 2020-03-05 18:04:31

How to hide and show two components?

I have a component that is being reused:

<app-add-object-layer-component *ngIf="showAddForm1()" [props]="null" [title]="'Добавление 1'"[type]="'addToB'">
 <app-add-object-layer-component *ngIf="showAddForm2()" [props]="null" [title]="'Добавление 1'"[type]="'addToL'">


As you can see, the display of components occurs due to ngIf:

showAddForm1()
showAddForm2()


The problem is that you only need to display one active component, hide the other. And I don't want to do something like this:

public onSelectButton(button: Button) {
    if (button instanceof ButtonAddToLayer) {
      this.addRegistryLayerService.add[addToB] = true;
    this.addRegistryLayerService.add[addToL] = false
    }
  }


How can this be done more elegantly - having a list of `app-add-object-layer-component` components?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Shvedov, 2020-03-05
@Junart1

ngSwitch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question