svg上的Angular - svg里面的$ sce.trustAsHtml在safari和ie中不起作用

时间:2015-06-10 12:52:17

标签: angularjs svg safari internet-explorer-11

我是angular and svg的新手,我似乎无法解决这个问题。

我在CheckBox元素上使用$sce.trustAsHtml。 我的代码在Chrome和Firefox中工作正常,但由于某种原因,它无法在Safari和IE11中附加变量。有什么想法吗?

P.S。我必须找到一种方法将内容链接到<g>,因为svg也有一些带有ng-repeat的动态内容(该部分很好)

在html中:

<g>

在js

  <svg xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px"y="0px" width="800px" height="800px" viewBox="0 0 800 800" enable-background="new 0 0 800 800" xml:space="preserve"><g ng-bind-html="svg"></g>.... other dynamic content...</svg>

jsfiddle:http://jsfiddle.net/a7dwcnkv/1/

如果我应该提供附加信息,请告诉我。 谢谢。

1 个答案:

答案 0 :(得分:0)

我没有使用ng-bind-html=""我为字符串中的每个路径使用ng-repeat,而是为特定属性添加了ng-attr-d ng-attr-fill等。这似乎在所有现代浏览器中都很好。

<path ng-attr-fill="{{path.fill}}" ng-repeat="path in infoSala.plan" ng-attr-stroke="{{path.stroke}}" ng-attr-stroke-miterlimit="{{path.strokew}}" ng-attr-d="{{path.code}}"></path>

希望这有助于其他人。