<tr *ngFor="let bidRequestDetail of (bidRequestsById.bidRequestDetails || bidResponseForm.get('bidResponseDetails').controls); let i=index">
<td class="table-primary">
<div><small>{{i+1}}</small></div>
</td>
<td class="table-secondary">
<div><small>{{bidRequestDetail.product}}</small></div>
</td>
<td class="table-primary">
<div><small>{{bidRequestDetail.description}}</small></div>
</td>
<td class="table-secondary">
<div><small>{{bidRequestDetail.quantity}}({{bidRequestDetail.unit}})</small></div>
</td>
<td class="table-primary">
<div><small>
<i class="fas fa-rupee-sign"></i> {{bidRequestDetail.quotedAmount}}</small></div>
</td>
<td class="table`enter code here`-secondary">
<div class="form-group">
<form formArrayName="bidResponseDetails" (click)="addbidResponseDetails()">
<div [formGroupName]="i">
<div class="input-group" #myDiv>
<input type="number" formControlName="quotedAmount" class="form-control" placeholder="Amount {{i}}"
[ngClass]="{ 'is-invalid': submitted && bidRequestDetail.controls.quotedAmount.errors }" />
<input type="number" formControlName="quantity" class="form-control" placeholder="quantity"
[ngClass]="{ 'is-invalid': submitted && bidRequestDetail.controls.quantity.errors }" />
<textarea type="text" formControlName="notes" class="form-control" placeholder="notes"
[ngClass]="{ 'is-invalid': submitted && bidRequestDetail.controls.notes.errors }"></textarea>
</div>
</div>
</form>
</div>
</td>
</tr>
当div标签加载时,我需要在formarray内部调用一个函数。 (点击)事件有效,即在点击时创建一个数组。我需要动态触发函数调用。
答案 0 :(得分:0)
您只需在组件的afterViewInit
生命周期挂钩中调用所需的函数,如下所示-
class MyComponent implements AfterViewInit {
ngAfterViewInit() {
this.addbidResponseDetails()
}
}
我在这里使用AfterViewInit
钩子,因为它是
一个回调方法,在Angular完成组件视图的初始化之后立即被调用。实例化视图时,仅调用一次。