My Angular 7 application includes a service that fetches data from a WebApi utilizing EntityFramework to retrieve information.
The issue arises when numeric fields with more than 18 digits are incorrectly displayed (e.g., the number 23434343434345353453,35 appears as 23434343434345353000) upon being received by the service. I've conducted tests confirming that EntityFramework is loading the data correctly. Interestingly, when data is inserted via my Angular application, it is done so accurately with the 18 or 20 digits required, thanks to the model being created with the big.js library.
Front-end: Angular Back-end: WebApi with ASP .NET MVC and EntityFramework
Component
import Big from 'big.js';
export class Parametro {
NRO_CONVENIO: string;
FEC_INICIO_NEGOCIACION: Date;
FEC_FIN_NEGOCIACION: Date;
VLR_CUPO_APROBADO: Big;
VLR_CUPO_UTILIZADO: Big;
VLR_CUPO_APROBADO_STORAGE: Big;
VLR_CUPO_UTILIZADO_STORAGE: Big;
ESTADO_DISPONIBLE: string;
ISEDIT: boolean;
}
export class ParametrosNegociacionService {
formData: Parametro;
list: Observable<Parametro>;
readonly rootURL = environment.baseUrl;
constructor(private http: HttpClient) { }
postParametro(formData: Parametro) {
return this.http.post(this.rootURL + '/ParametrosNegociacion', formData);
}
refreshList() {
this.http.get<Observable<Parametro>>(this.rootURL + '/ParametrosNegociacion')
.toPromise().then(res => {
this.list = res as Observable<Parametro>;
this.list.forEach(element => {
//Here the large number arrives badly
element.VLR_CUPO_APROBADO_STORAGE = element.VLR_CUPO_APROBADO;
});
});
}
...
}
View
<table id="dataTable" class="dataTable">
<thead class="headerStyle">
<tr>
<th>Vlr Cupo Aprobado</th>
</tr>
</thead>
<tbody>
<tr class="rowStyle" *ngFor="let emp of service.list">
<!--Here the large number showon badly -->
<td>{{emp.VLR_CUPO_APROBADO }}</td>
</tr>
</tbody>
</table>
Upon receiving data in the http.get request, the numeric values appear distorted.
How can I ensure the accurate reception of large numbers when requesting all information via the http.get?
I welcome any suggestions or ideas to resolve this issue.