在Select-Option标签中使用ng-bind-html或类似的东西

Roy*_*Roy 0 html javascript angularjs ngsanitize

我在下面有这个代码.这是使用NgOptions绘制表单中某些选项的直接方式.

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

}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)

我的问题是:我有什么方法可以选择在选择下拉列表中The Opt<sup>&trade;</sup>呈现The Opt 吗?因为我不能使用ng-bind-html.有什么办法可以实现吗?任何帮助表示赞赏.

Pra*_*epb 5

您可以使用ng-repeat,并使用ng-bind-html这一点.请参阅以下代码:

<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>
Run Code Online (Sandbox Code Playgroud)