Hi there I have a problem - Ionic 2 ionic 3 - ion-checkbox inside ngfor and with condition, such as ngIf or ngSwitch not working
I posted my code online with working and not working versions..
Working
<ion-list>
<ion-item *ngFor=" let answer of question.Answers">
<ion-label>{{answer.Description}}</ion-label>
<ion-checkbox (change)="change($event, answer)"></ion-checkbox>
</ion-item>
</ion-list>
<ion-list>
<ion-item *ngFor="let answer of question.Answers">
<ng-container *ngIf="QuestionType.MutipleChoice==question.QuestionType_Id">
<ion-label>{{answer.Description}}</ion-label>
<ion-checkbox (change)="change($event, answer)"></ion-checkbox>
</ng-container>
</ion-item>
</ion-list>
Not working 2
<ion-list>
<ion-item *ngFor=" let answer of question.Answers">
<ng-container [ngSwitch]="question.QuestionType_Id">
<ng-container *ngSwitchCase="QuestionType.MutipleChoice">
<ion-label>{{answer.Description}}</ion-label>
<ion-checkbox (change)="change($event, answer)"></ion-checkbox>
</ng-container>
</ng-container>
</ion-item>
</ion-list>
This one is working but only until I am trying to enter the checkboxes inside… Tried with templates , span tags instead of ng-container… etc…
<ion-list>
<ion-item>
<div *ngFor="let answer of question.Answers">
<div [ngSwitch]="question.QuestionType_Id">
<span *ngSwitchCase="QuestionType.YesNo">
<span *ngIf="answer.Description=='Yes'" style=" display: inline-block;">
<button ion-fab right><ion-icon name="checkmark"></ion-icon></button>
</span>
<span *ngIf="answer.Description=='No'" style=" display: inline-block;">
<button ion-fab color="danger" left><ion-icon name="close"></ion-icon></button>
</span>
</span>
<ng-container *ngSwitchCase="QuestionType.OneChoise">
{{ answer.Description }}
</ng-container>
<ng-container *ngSwitchCase="QuestionType.MutipleChoice">
{{ answer.Description }}
<!-- <ion-label>{{ answer.Description }}</ion-label> -->
<!-- <ion-checkbox color="dark" checked="answer.checked" [(ngModel)]="answer.checked"></ion-checkbox>
-->
</ng-container>
</div>
</div>
</ion-item>
</ion-list>
The ngSwitch works for other types like - yes no , or one choice , but not here when adding ion checkbox. The json is working also, meaning without the checkbox or without the switch I can see the multiple options.
Any ideas how I can solves this ? What am I missing? Puling hear for a day now…
Did anyone solve it?