Handing Precision of big number in Angular

Discussão em 'Angular' iniciado por Sheraz Ahmad, Outubro 19, 2024.

  1. Sheraz Ahmad

    Sheraz Ahmad Guest

    I have .Net Web API which returns data received from a third party API to my user facing Angular application. When API returns a big number like 999,999,999,999,999.99, Angular Changes it to 10,000,000,000,000,000. I don’t want to round this number as it’s sensitive data.

    There is a workaround in my mind to resolve this issue and retain the decimal place for such huge numbers. The workaround is to convert the numbers to string before sending the data back to the Angular app. Two ways to achieve this:


    1. Use some regular expression and make all number fields as string by placing quotes around the number.


    2. Currently, in the .NET API I am reading the response of the third party API as string and put it into a ContentString before sending it to the Angular app. Instead of reading the content as String, I can define a model and within that model I can define all the number type fields as String.

    I would like to know which one of these two approaches is better. I will really appreciate if someone can share some proper way to achieve this.

    Continue reading...

Compartilhe esta Página