$scope.不含結尾多餘小數金額 = function (value, 小數位) {
var s = $filter('currency')(value, '', 小數位);
if (s.indexOf('.') > 0 && s.right(1) == '0') s = trim(trim(s, '0'), '.');
return s;
}
function trim(s, c) {
if (c === "]") c = "\\]";
if (c === "\\") c = "\\\\";
return s.replace(new RegExp(
"^[" + c + "]+|[" + c + "]+$", "g"
), "");
}
String.prototype.right = function (num) {
return this.substring(this.length - num, this.length);
}
沒有留言:
張貼留言