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?
The uppercase Filter in AngularJS is used to change a string to an uppercase string or letters.
uppercase() Function in AngularJS is used to convert the string into uppercase.
Q 4 - Which of the following is true about uppercase filter? A - Uppercase filter is a function which takes text as input.
The uppercase filter converts a string to uppercase letters.
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
Use uppercase filter.
Take a look at this
var app = angular.module('myApp', []);
app.controller('ArrayController', function ($scope) {
$scope.currency_list = [
{
code: 'eur'
}, {
code: 'usd'
}
];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app='myApp' ng-controller="ArrayController">
<select ng-model="company.currency.code" ng-options="currency.code as (currency.code | uppercase) for currency in currency_list | uppercase">
</select>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With