在 AngularJS 中切换视图时如何让 MathML 正确呈现

How to get MathML to render properly when switching views in AngularJS

当我的网页最初加载时,它包含的任何 MathML 内容都将按预期呈现。但是,一旦我导航到另一个也包含 MathML 内容的视图,新内容就无法正确呈现。

如果我导航回初始视图,正确呈现的原始内容将不再如此。我正在使用带有 AngularJS 的 MathJax 库。

如何让 MathML 始终正确呈现?

示例代码在这里:https://github.com/JustCant/mathjax

我找到了这个问题的解决方案。

我创建了以下控制器并将其添加到我的 "app" 模块中:

.controller("mainCtrl", ["$rootScope", function($rootScope) {
  $rootScope.$watch(function() {
   MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
   return true;
  });
}]);

以下文档有更详细的解释: http://docs.mathjax.org/en/latest/advanced/typeset.html