Javascript 如何在角度控制器中过滤自定义数据

Javascript 如何在角度控制器中过滤自定义数据,javascript,angularjs,Javascript,Angularjs,我想过滤值remove decimal并在angular controller中添加$。。如果你有任何想法,请告诉我 $scope.data = [{ "key": " Logo", "color": "#004400", "values": [ [0, parseInt($scope.myappslogo)] ] }, { "key": "Sell", "color"

我想过滤值remove decimal并在angular controller中添加$。。如果你有任何想法,请告诉我

$scope.data = [{
        "key": " Logo",
        "color": "#004400",
        "values": [
            [0, parseInt($scope.myappslogo)]
        ]
    }, {
        "key": "Sell",
        "color": "#00cc00",
        "values": [
            [0, parseInt($scope.myapps.sell)]
        ].$filter('currency')
    }, {
        "key": "Total",
        "color": "#009900",
        "values": [
            [0, parseInt($scope.myapps.amount)] | currency
        ]
    }

]; 

$filter
的正确用法如下:

$filter('currency')($scope.myapps.amount);
您还可以添加选项:

$filter('currency')(amount, symbol, fractionSize)
所以我猜你想要这个:

$filter('currency')($scope.myapps.amount, '$', 0);

现在,如果您有一个值数组,您可以将上面的值放入函数并映射该数组。
e、 g:


我找到了解决办法。。。在d3选项中,我可以使用这样的过滤器

$scope.options = {
          chart: {
            type: 'multiBarHorizontalChart',
            height: 150,
            x: function (d) {
              return d[0];
            },
            y: function (d) {
              return d[1];
            },
            stacked: true,
             xAxis: {
                    showMaxMin: true
                },
             yAxis: {
                    axisLabel: 'Values',
                    tickFormat: function(d){
                        return d3.format('$')(d);
                    }
             }
          }
        };

你想做什么?你能添加一个需要使用5000000美元而不是50000.00美元的过滤值的数据before/afterinside值的示例吗?实际上,我正在使用d3.js作为图形。但在我的例子中,我如何使用呢?你一开始并没有提到这是用于图形的。所以这对你不起作用,我想你想要的是数字而不是字符串。仅供参考:将此
parseInt($scope.myappslogo)
替换为此
$filter($currency')($scope.myappslogo,“$”,0)
将提供您要求的格式。
$scope.options = {
          chart: {
            type: 'multiBarHorizontalChart',
            height: 150,
            x: function (d) {
              return d[0];
            },
            y: function (d) {
              return d[1];
            },
            stacked: true,
             xAxis: {
                    showMaxMin: true
                },
             yAxis: {
                    axisLabel: 'Values',
                    tickFormat: function(d){
                        return d3.format('$')(d);
                    }
             }
          }
        };