目标
使用Jhipster v5.0.1和Angular v6.0.0
为列表中存在的每个对象创建一个输入,以便我可以正确地显示它并在服务器中检索它。
尝试
Apples appear 2 times in this file
Apples appear on these lines: 1, 2,
问题
我找不到解决办法。
EDIT EDIT EDIT
使用每个对象的特定名称,它可以正常工作:
my $filename = "<file.txt";
open( TEXT, $filename );
$initialLine = 10; ## holds the number of the line
$line = 0;
$counter = 0;
# holder for line numbers
@lineAry = ();
while ( $line = <TEXT> ) {
chomp( $line );
if ( $line =~ /Apples/ ) {
while ( $line =~ /Apples/ig ) {
$counter++;
}
push( @lineAry, $counter );
$initialLine++;
}
}
close( TEXT );
# print "\n\n'Apples' occurs $counter times in file.\n";
print "Apples appear $counter times in this file\n";
print "Apples appear on these lines: ";
foreach $a ( @lineAry ) {
print "$a, ";
}
print "\n\n";
exit;
但是,无论发生什么情况,errorMessages都将保持隐藏状态。“逻辑上”它不是正确的名称:
<div class="table-responsive" *ngIf="map">
<form name="editForm" role="form" #editForm="ngForm" id="editForm">
<table class="table table-striped table-bordered" *ngIf="arrayOfArrays">
<thead>
<tr>
<th> Type Mission </th>
<th *ngFor="let arrayOfArray of arrayOfArrays[0]"> {{arrayOfArray.jourDuMois | date:'EEEEE d'}} </th>
</tr>
</thead>
<tbody>
<tr *ngFor="let keyOfMap of keysOfMap ; let i= index" >
<td> {{keyOfMap}} </td>
<td *ngFor="let arrayOfArray of arrayOfArrays[i] ; let f = index " >
<input class = "form-control-plaintext" name="quantite" [(ngModel)]="arrayOfArray.quantite" required pattern="(0|0.5|1)">
<div [hidden]="!(editForm.controls.quantite?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.quantite?.errors?.required">
Le champ est requis.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.quantite?.errors?.pattern">
Valeurs acceptées: 0, 0.5 ou 1
</small>
</div>
</td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" (click)="saveDetailsForCra()" [disabled]="editForm.form.invalid || isSaving"> <fa-icon [icon]="'save'"></fa-icon> Sauver </button>
</form>
</div>
但是,如果我输入特定名称:
<input class = "form-control-plaintext" name="quantite{{i}}{{f}}" [(ngModel)]="arrayOfArray.quantite" required pattern="(0|0.5|1)">
我收到一条错误消息:
解析器错误:在[!(editForm.controls.quantite {{i}} {{f}} ?. invalid}]无效的第28列中有表达式需要插值({{}})
可以帮我吗?
谢谢!
答案 0 :(得分:1)
我在这里找到了解决方法:
Angular2 ngModel inside ngFor (Data not binding on input)
每个输入都需要使用不同的名称,因此我只添加了索引i和f。
谢谢。