I have a chip list, depending on the chip being clicked it will change. If user clicks the "gasoline" chip, template switches to source and destination input, if it clicks on hotel, it turns a tag input. My difficulty is to transform these template depedending on the condition
<div fxFlex="100">
<mat-form-field fxFlex ngStyle.gt-sm="margin-left:30px" *ngIf="descriptionTags == 'default'; else tagDescription">
<input matInput placeholder="Descrição" ngStyle.gt-sm="margin-left:30px">
</mat-form-field>
<ng-template #tagDescription>
<mat-chip-list class="mat-chip-list">
<mat-chip *ngFor="let tags of descriptionTags" value>
{{tags.nameTag}}
</mat-chip>
</mat-chip-list>
</ng-template>
<ng-template #inputListTags>
<h1>TAG INPUT LIST</h1>
</ng-template>
<ng-template #OriginDestinationReason>
<h1>TAG Origin Destination adn Reason</h1>
</ng-template>
<ng-template #OriginDestination>
<h1>TAG Origin Destination</h1>
</ng-template>
</div>
Since you're using the
descriptionTags
property as an Object Array and as astring
, you can specify the type ofdescriptionTags
asdescriptionTags: (string | any[])
You can then switch between them whenever you like. In this example, I've made the switch based on the button that was clicked.
Here's a Sample StackBlitz for your ref.