Javascript 如何在使用mathjax从服务器查看html时避免angularjs上的解析错误

Javascript 如何在使用mathjax从服务器查看html时避免angularjs上的解析错误,javascript,angularjs,ckeditor,mathjax,Javascript,Angularjs,Ckeditor,Mathjax,我试图在angularjs中使用mathjax。我在服务器上有很多html内容,它也需要编辑。 这是我用来触发mathJax进行渲染的指令 app.directive("mathTex", ['$log',function($log) { return { restrict: "C", link: function(scope, element, attributes) { var currentElement = element[0]; //alert(

我试图在angularjs中使用mathjax。我在服务器上有很多html内容,它也需要编辑。 这是我用来触发mathJax进行渲染的指令

app.directive("mathTex", ['$log',function($log) {
return {
    restrict: "C",
    link: function(scope, element, attributes) {
      var currentElement = element[0];
      //alert("mathJax directive called");
      MathJax.Hub.Queue(["Typeset", MathJax.Hub, element[0]]); 
    }
}}]);
我正在使用另一个指令编译范围中任何更改的html

app.directive('dynamicHtmlCompile', ['$compile','$parse','$log','$sanitize', function ($compile, $parse, $log, $sanitize) {
    return {
    restrict: 'A',
    replace: true,
    link: function (scope, ele, attrs) {
      scope.$watch(attrs.dynamicHtmlCompile, function(html) {
        ele.html(html);
        $compile(ele.contents())(scope);
      });
    } 
  }
}]);
这两个指令都在正常条件下工作,但都适用于以下表达式

\({2v}}/2\)
,由于表达式中的花括号,它触发了一个错误

Error: [$parse:syntax] Syntax Error: Token 'v' is an unexpected token at column 2 of the expression [2v] starting at [v].
对于编辑内容,我使用mathjax和ckeditor。它也很好用

到目前为止,我尝试了“nghtmlbind”,我无法使用它,因为它不支持双向绑定。另一个选项是更改插值开始和结束符号。我在项目中使用了一些库,我不想为了解决这个问题而把事情搞砸

我可以控制html的源代码,如果有必要,我可以选择更改(可能是查找和替换)格式或文本。如有任何建议,将不胜感激


谢谢

在调用$compile之前,您可以尝试用其他字符替换{{和}},并将其替换回mathTex指令。@jcubic谢谢。它起作用了。至少现在是这样。从服务器返回的html可以是包含大量内容的整个html页面。我正在寻找一种解决方案,在从服务器接收页面时重新呈现页面。我不需要触发除math-tex指令以外的任何东西。