我想按顺序显示按钮视图,以便使用选择框更改答案类型。 QuestionType 值一直在变化,但使用* ngIF时,它不会在浏览器中显示正确的按钮视图。 它位于Reactive Forms模块的表单数组中。
以下是代码:
<ng-container formArrayName="AnswersList">
<tr *ngFor="let itemrows of itemrow.controls.AnswersList.controls; let ansi=index" [formGroupName]="ansi">
<td *ngIf="SurveyForm.controls.Questions.controls.QuestionType==2">
<mat-checkbox [disabled]="true"></mat-checkbox>
</td>
<td *ngIf="SurveyForm.controls.Questions.controls.QuestionType==1">
<mat-radio-group [disabled]="true">
<mat-radio-button value="1"></mat-radio-button>
</mat-radio-group>
</td>
<td style="width:100%;">
<input matInput placeholder="Enter an answer choice" formControlName="Answer" class="td_radio_button" *ngIf="open_input_choice" required>
</td>
<td *ngIf="itemrow.controls.AnswersList.controls.length>1">
<i class="material-icons" style="position: absolute;right:60px;margin-top:-13px;cursor: pointer;" (click)="removeAnswers(itemrow,ansi)">remove_circle_outline</i>
</td>
</tr>
</ng-container>
请提供有关如何解决此问题的建议:Plnkr链接:https://plnkr.co/edit/SWjYmV9d8LLDMc1V58iZ?p=preview