My query is somewhat linked to this specific response, although with a slight variation.
What I am aiming to accomplish is the parsing of HTML entities from a string passed onto a select
using ng-options
. Consider the following dataset:
$scope.myOptions = [{
text: '10.00 €',
val: 10
},{
text: '25.00 €',
val: 25
},{
text: '50.00 €',
val: 50
}];
And this template:
<select class="form-control" ng-model="desiredAmount"
ng-options="opt.val as opt.text for opt in myOptions">
</select>
I wish for the €
entity to be displayed as €, rather than its actual format (I understand why it's not working, as Angular interprets the data as plain text). Is there a solution to this issue?
Here is a jsbin that I created to illustrate my predicament.
PS - I am aware that I can achieve this using
<option ng-repeat="opt in myOptions">{{opt.text}} €</option>
However, this creates an additional problem with an empty initial option appearing, which is why I prefer sticking to the ng-option
method. Regardless, I would like to know if it is feasible to have a string parsed when utilizing ng-option
.