0

I have this code below. Which is a straight forward way of using NgOptions to plot some options in a form.

function NameCtrl($scope) {
  $scope.theOptions = [{
    'label': 'The Opt<sup>&trade;</sup>',
    'id': 3
  }]

}
<html ng-app>

<head>
  <meta charset="utf-8">
  <title>Angular.js Example</title>
  <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script>

</head>

<body ng-controller="NameCtrl">
  <select ng-model="selectedOption" ng-options="x.id as x.label for x in theOptions">
        <option value="">Select</option>
      </select>
</body>

</html>

My question is: Is there any way I can make the Option The Opt<sup>&trade;</sup> to render The Opt in a Select Dropdown? As I cannot use ng-bind-html. Is there any way I can achieve this? Any help is appreciated.

SAMUEL
  • 8,098
  • 3
  • 42
  • 42
Roy
  • 1,939
  • 1
  • 14
  • 21

2 Answers2

6

You can use ng-repeat and use ng-bind-html with that. See the code below:

<select ng-model="selectedOption">
    <option value="">Select</option>
    <option ng-repeat="x in theOptions" ng-bind-html="x.label" value="{{x.id}}" id="{{x.id}}"></option>
</select>
Pradeepb
  • 2,564
  • 3
  • 25
  • 46
1

If you need to use ng-options, here are a few related solutions and here's a plunker showing this solution with your code. Hope this helps. Note that I also changed your tags to an html entity code.

Community
  • 1
  • 1
hughesjmh
  • 2,133
  • 2
  • 11
  • 11
  • Selecting this as a "Correct" answer because in this method I don't need to change my HTML and probably JS too. Rather it will be much easier just to change my resource bundle. Plus using `ng-repeat` to obtain Select-option Dropdown is frowned upon. – Roy Mar 29 '17 at 18:59