Reputation: 57
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
<li class="temp">Temperature <span> {{Temperature.Ch1Temp | number:0}} </span></li>
Upvotes: 0
Views: 630
Reputation: 11613
Why not Math.floor()
?
<li class="temp">Temperature <span>{{ Math.floor(Temperature.Ch1Temp) }}</span></li>
Just keep in mind how that will also impact negative numbers.
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.
If you're using a modern Angular, you'll need to explicitly assign the Math
library in your component's Typescript, like this:
export class AppComponent {
number = 3.7;
Math = Math; //explicitly bind the Math library so it's usable in template
}
There's a working Stackblitz example HERE:
Upvotes: 1
Reputation: 1
You could convert the number into an int using parseInt
inside a js function
Upvotes: 0