javascriptangularjsng-options

Filter uppercase with ng-options


I didn't find how to uppercase or uppercase first letter in ng-options.

My select:

<select ng-model="company.currency.code" ng-options="currency.code as currency.code for currency in currency_list>
</select>

In controller:

$scope.currency_list = [
    {
        code: 'eur'
    }, {
        code: 'usd'
    }
];

I'd like to print "EUR", "USD", or "Eur", "Usd" without looping manually my object.

Is that possible to do this?


Solution

  • This should work:

    ng-options="currency.code as (currency.code | uppercase) for currency in currency_list"
    

    See the filter docs: https://docs.angularjs.org/api/ng/filter/uppercase