HTML:
<input #inputCodigo type="text" (keyup)="searchProductoBarCode($event)">
</div>
</article>
<article *ngIf="proforma && proforma.productos.length">
<table #tableDispatch tabindex="-1" [attr.role]="role-table" appScrolling [data]="productosDespachados"
(selected)="productoSelected=$event">
<thead>
<tr>
<th>Código</th>
<th>Producto</th>
<th>Cantidad</th>
<th>Fracción</th>
<th>P.unitario</th>
<th>P.total</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let p of productosDespachados; let i=index" [class.selected]="onSelected(p,i)">
<td>{{ p.prod_codigo }}</td>
<td>{{ p.prod_descripcion }}</td>
<td><input type="text" (keyup)="onKeyDownInput($event,i)" #inputsCantidad></td>
<td>{{ p.prec_vta_final }}</td>
<td>{{ getPrecioFinalv2() }}</td>
<td>{{ p.prod_stock_cantidad }}</td>
</tr>
</tbody>
</table>
Function onSelected()
, repeats multiple times without stopping, and slows my application, the function onSelected()
, returns true or false depending on the case:
onSelected(producto, index) {
const result = Object.is(producto, this.productoSelected);
if (result) {
this.inputsFraccion.toArray()[index].nativeElement.focus();
}
return Object.is(producto, this.productoSelected);
}