Javascript 如何使用jquery添加包含AngularJS表达式的ajax加载内容

Javascript 如何使用jquery添加包含AngularJS表达式的ajax加载内容,javascript,jquery,html,angularjs,ajax,Javascript,Jquery,Html,Angularjs,Ajax,我遇到了这些问题,希望你能给我指出正确的方向 这是你的电话号码 解释者 1) 我通过ajax请求收到一些html模板,一切正常这就是它的外观: <div> <h2 class="splash" ng-bind="view.headline || 'That&#039;s cool'"></h2> </div> 您是否尝试过: <!-- you can just escape t

我遇到了这些问题,希望你能给我指出正确的方向

这是你的电话号码

解释者

1) 我通过ajax请求收到一些html模板,一切正常这就是它的外观:

        <div>
            <h2 class="splash" ng-bind="view.headline || 'That&#039;s cool'"></h2>
        </div>
您是否尝试过:

<!-- you can just escape the one apostrophe -->
<h2 ng-bind="view.headline || 'That\'s cool'"></h2> 

另一种方式:

首先,将模板分离到另一个文件,这样更容易:

myTemplate.html

<h2 ng-bind="view.headline || 'That\'s cool'"></h2> 
<!-- you can just escape the one apostraphe, but really, 
this logic doesn't belong in the html, but rather the 
controller or service which assigns a value to view.headline -->

然后,您可以包括您的模板:

<div id="thisIsMyTemplatePlaceholder" ng-include="'myTemplate.html'"> </div>

显示此功能的Plunker:

尝试两次转义。 当
html()
unescape您的字符串时,将删除一个转义符,请参阅以获取参考

'That\\'s cool'\">That's cool</h2>";

这是你想要的效果,还是只会
那样';s cool
工作?

您不应该将jQuery与Angular混合在一起,如果您有一个要粘贴到页面中的模板,您应该使用一个指令。因此,要解决您的问题,请使用ng include粘贴您的模板。能否详细说明您对模板的调用是什么样子的?URL结构是什么?这是可行的,但我仍在寻找一种使用jquery实现这一点的方法。谢谢你的厚礼!
<h2 ng-bind="view.headline || 'That\'s cool'"></h2> 
<!-- you can just escape the one apostraphe, but really, 
this logic doesn't belong in the html, but rather the 
controller or service which assigns a value to view.headline -->
<div id="thisIsMyTemplatePlaceholder" ng-include="'myTemplate.html'"> </div>
'That\\'s cool'\">That's cool</h2>";
view.headline || 'That\'s cool