Bin*_*and 6 salesforce angularjs
我使用Salesforce作为后端,我的用户可以获得一些通知,其中可能包含带有指向某处的链接的标记.这就是说我在控制器中使用$ sce来执行这样的功能:
vm.to_trusted = to_trusted;
function to_trusted(html_code) {
return $sce.trustAsHtml(html_code);
}
Run Code Online (Sandbox Code Playgroud)
在前端我正在使用它:
<p ng-bind-html="vm.to_trusted(message.body)"></p>
Run Code Online (Sandbox Code Playgroud)
返回的message.body的示例是
<a href="/#/app/profile">Click Here to Fill out your Profile</a>. It will allow you
Run Code Online (Sandbox Code Playgroud)
在localhost上,这显示了链接显示而不是标记.在Salesforce上,情况并非如此,而是显示上面的内容.关于为什么这不起作用的任何想法?
更新:
是的我确实包含了ngSanitize :)
Salesforce@dispatch请求以奇怪的方式序列化文本。
如果 Salesforce 字符串的内容是:'<a href="">Things</a>'您将在 Angular 中看到您已收到:<a href="$quot;>Things<a>
我找到的解决方案是在您的控制器中:
function to_trusted(html_code) {
// Cause the <g; etc become '<'
return $('<textarea />').html(html_code).text();
}
Run Code Online (Sandbox Code Playgroud)
因为 Salesforce。
| 归档时间: |
|
| 查看次数: |
104 次 |
| 最近记录: |