不确定以前是否有人遇到过这种情况,在谷歌上查找我似乎找不到例子。基本上,我正在创建一个很长的 html 模板,并将其包装在 ng-bing-html 中,它加载我的 html,但它不加载我的插值。让我给你一个简单的例子:
Controller :
$scope.example_text_here = "Hello World!"
$scope.HTML_template = "<p><strong> Example: </strong> {{ example_text_here }}</p>"
HTML:
<div ng-bind-html="HTML_template"></div>
输出
Example: {{ example_text_here }}
我的期望:
Example: Hello world!
有人知道如何实现这一点吗?
最佳答案
您应该使用 $interpolate 模块,然后注入(inject)当前范围甚至 $compile。查看更多https://docs.angularjs.org/api/ng/service/ $插值
$interpolate($scope.HTML_template)($scope)
关于javascript - AngularJS - 在 html 模板中使用插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52518070/