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;
- }
- )};
- "showresult">
{{Resuts}}
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

Rajesh GamiPosted May 17, 2018, 1:43 AM