javascripthtmlangularjsngsanitize

Using ng-bind-html or something similar in Select-Option tag


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.


Solution

  • 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.