Skip to content Skip to sidebar Skip to footer

How To Remove Decimal Part From The Data In Angular Js

While im removing the decimal , its getting round off . but i want to remove decimal point only. while my data is 3.7 , im getting 4. sample data 3.7 Exp op 3 code
  • Copy

    Just keep in mind how that will also impact negative numbers.

    Angular JS

    Furthermore, as mentioned in the comments, you will need to bind the Math library into your controller, as described in this answer, and excerpted as follows:

    $scope.Math = window.Math;
    

    AngularJS Example HERE.

    Modern Angular

    If you're using a modern Angular, you'll need to explicitly assign the Math library in your component's Typescript, like this:

    exportclassAppComponent {
      number = 3.7;
      Math = Math; //explicitly bind the Math library so it's usable in template
    }
    

    There's a working Stackblitz example HERE:

  • Solution 2:

    You could convert the number into an int using parseInt inside a js function

    Post a Comment for "How To Remove Decimal Part From The Data In Angular Js"