vendredi 16 août 2019

How to Implement Nested NG If else conditions in Angular 8

What i need

        if(field.ajax && field.ajax='Y' && field.multiple&& field.multiple=='Y')
        {

        }
        else if (field.ajax && field.ajax='Y' && multiple.ajax && field.multiple=='N'))
        {
        }
        else
        {
        }

for 2 conditon works

   <ng-container *ngIf="field.ajax && field.ajax === 'Y'; else select2ElseBlock">
              <ng-select
              [items]="data"
              multiple="true"
              bindLabel="name"
              [closeOnSelect]="true"
              [loading]="loading"

              [searchable]="true"
              [clearable]="true" 
              (click)="clearModel()"
              (keyup)="changed($event.target.value)">
              </ng-select>
        </ng-container>
       <ng-template #select2ElseBlock>
              <ng-select
              [items]="field.choices.choice"
              multiple="true"
              bindLabel="name"
              [loading]="loading"
              >
              </ng-select>
        </ng-template>

But for multiple case create problem.

  • how can implement nested if else conditions in Angular 8.

Refrence

https://angular.io/api/common/NgIf

Aucun commentaire:

Enregistrer un commentaire