From caf1fda1987844bb2f8cbd3b8bdb0c8ac55447c7 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Tue, 17 May 2016 21:52:59 +0800 Subject: [PATCH] fix the value of completed percent is wrong --- app/index.html | 1 + app/scripts/filters/percent.js | 12 ++++++++++++ app/views/list.html | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/scripts/filters/percent.js diff --git a/app/index.html b/app/index.html index 1720915..e57a03a 100644 --- a/app/index.html +++ b/app/index.html @@ -190,6 +190,7 @@ + diff --git a/app/scripts/filters/percent.js b/app/scripts/filters/percent.js new file mode 100644 index 0000000..87abcfc --- /dev/null +++ b/app/scripts/filters/percent.js @@ -0,0 +1,12 @@ +(function () { + 'use strict'; + + angular.module("ariaNg").filter('percent', ['numberFilter', function (numberFilter) { + return function (value, precision) { + var ratio = Math.pow(10, precision); + var result = parseInt(value * ratio) / ratio; + + return numberFilter(result, precision); + } + }]); +})(); diff --git a/app/views/list.html b/app/views/list.html index 31ee58f..6a5410a 100644 --- a/app/views/list.html +++ b/app/views/list.html @@ -11,7 +11,7 @@ aria-valuenow="{{task.completePercent}}" aria-valuemin="1" aria-valuemax="100" style="width: {{task.completePercent}}%;">
+ ng-bind="(task.completePercent | percent: 2) + '%'">