admin管理员组文章数量:1336631
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>™</sup>',
'id': 3
}]
}
<html ng-app>
<head>
<meta charset="utf-8">
<title>Angular.js Example</title>
<script src="//cdnjs.cloudflare/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>
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>™</sup>',
'id': 3
}]
}
<html ng-app>
<head>
<meta charset="utf-8">
<title>Angular.js Example</title>
<script src="//cdnjs.cloudflare./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>™</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.
2 Answers
Reset to default 6You 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>
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.
本文标签: javascriptUsing ngbindhtml or something similar in SelectOption tagStack Overflow
版权声明:本文标题:javascript - Using ng-bind-html or something similar in Select-Option tag - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742404429a2468529.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论