TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mahesh Reddy
NA
363
17.4k
Decimal floating number should not exceed more than 2(2.11)
Jan 2 2019 12:13 AM
Hi,
In invoice i have 2 fields named as qty and price
i have stored these variables in one array
total number should not 2 decimals
Ex:123.12(I need like this)
123.123(I don't need)
Could kindly any one help me
Here my sample code
<tbody>
<tr ng-repeat="item in invoice.items">
<td><input type="number" ng-model="item.qty" class="form-control" /></td>
<td><input type="number" ng-model="item.price" class="form-control" /></td>
<td>{{item.qty * item.price}}</td>
</tr>
<tr>
<td><button type="button" class="btn btn-primary" ng-click="add()">Add item</button></td>
<td></td>
<td></td>
<td>Total : </td>
<td>{{total()}} €</td>
</tr>
</tbody>
Sum of ng repeat elements
..........................
$scope.total = function(){
var total = 0;
angular.forEach($scope.invoice.items, function(item){
total += item.qty * item.price;
})
return total;
}
});
Reply
Answers (
5
)
Code to clear mat radio button select.
Angular 7 Service