我在Angular 4工作,我想根据我的* ngFor循环中的变量修改html标签。这是我尝试构建的代码:
<mat-card-content *ngFor="let question of questionGroup.profileQuestion class="mat-elevation-z2">
<!-- I would like to do something like this in a *ngIF and isQASideBySide
is a boolean value -->
<div class="container" *ngIf="questions.isQASideBySide THEN fxLayout.xs='row' ELSE fxLayout.xs='column'" fxLayoutGap.xs="0" fxLayoutGap="10px">
<div fxFlex="50%" fxFlexOrder="1" style="padding:10px">
<p>
{{ question.profileQuestionText }}
</p>
</div>
<div fxFlex="50%" fxFlexOrder="1" style="padding:10px" >
<!-- INPUT CONTROLS ....-->
</div>
</div>
</mat-card-content>
答案 0 :(得分:2)
尝试使用三元运算符的属性绑定,如:
myTableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.bottom)
答案 1 :(得分:0)
答案 2 :(得分:0)
修改后的代码
这里的工作是OP的最终代码(从问题本身移开):
<mat-card-content *ngFor="let question of questionGroup.profileQuestion class="mat-elevation-z2">
<div class="container" [fxLayout]="question.isQASideBySide ? 'row' : 'column'" fxLayoutGap.xs="0" fxLayoutGap="10px">
<div [fxFlex]="question.isQASideBySide ? '50%' : '100%'" fxFlexOrder="1" style="padding:10px">
<p>
{{ question.profileQuestionText }}
</p>
</div>
<div fxFlex="50%" fxFlexOrder="1" style="padding:10px" >
<!-- INPUT CONTROLS ....-->
</div>
</div>
</mat-card-content>