javascript - 在 AngularJS 中切换 View 时如何让 MathML 正确渲染

标签 javascript angularjs mathjax mathml

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

如果我导航回初始 View ,正确呈现的原始内容将不再正确呈现。我将 MathJax 库与 AngularJS 一起使用。

如何让 MathML 始终正确渲染?

此处找到示例代码:https://github.com/JustCant/mathjax

最佳答案

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

我创建了以下 Controller 并将其添加到我的“应用程序”模块中:

.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

关于javascript - 在 AngularJS 中切换 View 时如何让 MathML 正确渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54219839/

相关文章:

javascript - 有关 javascript 函数在 div 悬停时未触发的问题

javascript - Meteor排行榜示例JS模式解释

javascript - 如何在angularjs中使用通配符搜索?

php - 带有 Angularjs 的 Codeigniter 中的文件夹结构应该是什么

html - 如何将公式转换为 MathML 以便在网页中使用

javascript - 在 html 中访问动态 $scope 变量

javascript - 如何在 jQuery 中使用变量 id 作为选择器

javascript - Cordova 文件传输 |如何将标题中的字符串放入 TargetPath?

javascript - 如何在 MathJax 中更改方程颜色

svg - tex-mml-svg.js :1 Uncaught Error: Unknown node type "body" while creating MathJax SVG