基于以下分隔符,如何以角度js显示数字
格式化示例如下:
Format Input Output
######### 100000000 100000000
###,###,### 100 100
###,###,### 10000 10,000
###,###,### 100000 100,000
###,###,### 1000000 1,000,000
###,###,### 100000000 100,000,000
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
</head>
<body style="font:15px Verdana;" ng-app="myApp">
<div ng-app>
<p>
<label>Enter a number</label>
<input type="text" ng-model="bid" />
</p>
<p> {{ bid | PointsFormater }} </p>
</div>
</body>
<script>
var app = angular.module('myApp', []);
app.filter('PointsFormater', function() {
return function(x) {
var delimiter = "###,##,###,#0.00";
var decArr=delimiter.split(",");
if(decArr.length>1){
for(var i=0; i< decArr.length; i++){
console.log(decArr[i]);
console.log(decArr[i].length);
}
}
return x;
};
});
</script>
</html>
根据分隔符值,结果应该是这样的 123,45,6789,10.00
示例: - JS fiddle