user2093511
user2093511

Reputation: 21

AngularJs currency filter

I would like to add the | currency filter to just the field following field:
{ title: localizationBundle.AverageGross, field: 'AvgGrossDays30', visible: true }

If I use the following, but it adds the currency filter to all of them:

{{fsiItem[column.field] | currency}}

Any assistance and guidance would be appreciated.

 <tr ng-repeat="fsiItem in $data">
                <td ng-repeat="column in columns" ng-show="column.visible" sortable="false">
                    {{fsiItem[column.field]}}
                </td>
            </tr>


$scope.columns = [
                { title: localizationBundle.FastestSellingGroupName, field: 'FastestSellingGroupName', visible: true },
                { title: localizationBundle.Sales180Days, field: 'SaleDays180', visible: true },
                { title: localizationBundle.Sales30Days, field: 'SaleDays30', visible: true },
                { title: localizationBundle.InStock, field: 'InStock', visible: true },
                { title: localizationBundle.AverageGross, field: 'AvgGrossDays30', visible: true }
    ];

Upvotes: 1

Views: 139

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136154

You could do by simply applying conditional Ternary operator

<td ng-repeat="column in columns" ng-show="column.visible" sortable="false">
 {{column.field == 'AvgGrossDays30' ? (fsiItem[column.field]| currency): fsiItem[column.field]}}
</td>

Upvotes: 1

Related Questions