问题描述
我想为站点上的每个问题创建inputfield
,但是inputfields
彼此相邻。我想创建位于另一个inputfields
下的inputfield
。
HTML看起来像这样:
<li *ngFor="let item of unteraufgaben; let i = index">
<form [formGroup]='antwort'>
<mat-form-field>
<input matInput placeholder="Antwort" [type]="'text'" name="unterantwort"
[formControl]="antwort.get('antwort'+i)" autocomplete="off">
</mat-form-field>
</form>
</li>
网站图片如下:
解决方法
在<br>
元素之后尝试<input>
。
您可以将mat-form-field
放在div
内,并赋予div
样式->
display- flex,flex-direction- column
尝试一下:
<form [formGroup]="antwort">
<ul *ngFor="let item of unteraufgaben; let i = index">
<li class="list-unstyled clearfix">
<mat-form-field>
<input matInput placeholder="Antwort" [type]="'text'" name="unterantwort" [formControl]="antwort.get('antwort'+i)" autocomplete="off">
</mat-form-field>
</li>
</ul>
</form>
,或者如果您真的不需要无序列表,则只需使用以下选项:
<form [formGroup]="antwort">
<div *ngFor="let item of unteraufgaben; let i = index">
<mat-form-field class="clearfix">
<input matInput placeholder="Antwort" [type]="'text'" name="unterantwort" [formControl]="antwort.get('antwort'+i)" autocomplete="off">
</mat-form-field>
</div>
</form>