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
Rajesh Gami
79
24.4k
1.3m
Display only 2 decimal point : AngularJS 1.0
May 16 2018 11:22 PM
How to display only 2 decimal point in output of angularJS.
Supppose my percentage is 81.6777776777 % but i want to display it 81.67 % .
My code of angularJS:
Controller.js
app.controller(
"AngularJs_ImageController"
,
function
($scope, $timeout, $rootScope, $window, $http, myService) {
$scope.finalSubmit =
function
() {
$http({
method:
'POST'
,
url:
'/Exam/FinalSubmit/'
//params: { ESTQUserAnswer: setUserAns, ESTQId: ESTQId, ESTQIsMark: ESTQIsMark }
});
$scope.txtAnswer =
""
;
var
percentage = ($scope.totalPoints * 100) / $scope.textbox;
// E.X (3 * 100) / 7 = 42.85714285714286
$scope.Resuts1 =
"You gotted "
+ percentage +
" %"
;
if
(percentage >= 70) {
$scope.Resuts =
"You are Pass "
+ $scope.Resuts1;
swal(
"Pass"
,
"You are Pass "
+ $scope.Resuts1,
"success"
)
$scope.ImageAnswer =
"won.png"
;
}
else
{
$scope.Resuts =
"Sorry "
+ $scope.usrName +
" You are Fail "
+ $scope.Resuts1;
swal(
"Fail"
,
"You are fail "
+ $scope.Resuts1,
"error"
)
$scope.ImageAnswer =
"lose.png"
;
}
$scope.showGameStart =
false
;
$scope.showGame =
false
;
$scope.showresult =
true
;
return
;
return
;
}
)};
in view Result.cshtml
<div ng-show=
"showresult"
>
<p> {{Resuts}} </p>
</div>
Output is:
Sorry Rajesh You are Fail, You gotted
42.85714285714286
%
But i want to display this to: 42.85 % , How is possible in angularJS.
Thanx in advance
Reply
Answers (
1
)
Display Image in Angular 6
How to reset value of Dropworn to default after submit?