gpt4 book ai didi

javascript - ng-bind-html 不适用于 ng-options

转载 作者:搜寻专家 更新时间:2023-11-01 04:17:20 24 4
gpt4 key购买 nike

我需要清理选项中的特殊字符,但它无法正常工作。也许任何人都可以告诉我应该如何正确地做到这一点?

例如:

HTML:

<div ng-controller="Ctrl">
<select id="limitType" name="limit" ng-model="selectedLimit" ng-options="limit.text for limit in limits" ng-init="selectedLimit='5'" ng-bind-html="limit.text"></select>
<div>

JS:

var app = angular.module('app', ['ngSanitize']);

function Ctrl($scope) {
$scope.limits = [{
text: 'Afficher &#0153; par page'
}, {
text: 'Afficher 10 par page'
}, {
text: 'Afficher 15 par page'
}, {
text: 'Afficher 20 par page'
}];
}

这是 fiddle 上的链接:http://jsfiddle.net/rfTV2/3/

最佳答案

您有三个选择。

  1. 您可以直接在源代码中包含 unicode 字符
  2. 你可以convert the html entities to unicode in the browser using JavaScript
  3. 或者您可以 fall-back to ng-repeat and use ng-bind-html on your option tag .

关于javascript - ng-bind-html 不适用于 ng-options,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21187360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com