【发布时间】:2018-07-08 22:42:48
【问题描述】:
我正在尝试在 Angular 6 中将 fxFlex 属性与 ngIf 一起使用,但是,它的行为非常奇怪并且没有给出预期的输出。
Here is a link to a demo showing the issue on stackblitz
我希望它看起来像 like this when it works correctly
在那个演示中,在前两个输入中,我尝试了两种将 fxflex 放在输入上的方法,但它对这两种输入的作用都很奇怪,如果我将 fxFlex 放在 ngIf div 上,它会给出错误的大小和间距:
<div *ngIf="true" fxFlex = "20">
<mat-form-field >
<input matInput name="dependentRelationship" placeholder="Relationship" [(ngModel)]="data.dependentRelationship"
required>
</mat-form-field>
</div>
它可以在没有 ngIf 的情况下正常工作,给出预期的大小和间距:
<mat-form-field fxFlex = "20">
<input matInput name="dependentRelationship" placeholder="Relationship" [(ngModel)]="data.dependentRelationship"
required>
</mat-form-field>
有人可以说明为什么 fxFlex 不能按预期使用 ngIf 吗?
【问题讨论】:
标签: angular flexbox angular-material2 angular6