Angular JS Mathml视图未处理

Angular JS Mathml views not processing

本文关键字:未处理 视图 Mathml JS Angular      更新时间:2023-09-26

我有一个用Mathml显示视图的应用程序。未处理Math标记。我必须刷新页面才能处理它们。

我的视图包含一个控制器和MathMl标签,如:

moment lone.html

 <math xmlns="http://www.w3.org/1998/Math/MathML">
   <msub><mi>I</mi><mn>x</mn></msub><mtext>&nbsp;et&nbsp;</mtext><msub><mi>I</mi><mn>y</mn></msub> 
 </math>

Angular应用程序路由到view.html

var mid = angular.module('mid', [
  'ngRoute'
]).
config(['$routeProvider', function($routeProvider) {
  $routeProvider.
    when("/moment", {templateUrl: "moment-lone.html", controller: "momentCtrl"}).
    otherwise({redirectTo: 'index'});
}]);

应用程序正在运行。但是,mathjax不会处理期望的标记,因为它是在标记之前加载的。这是使用Chrome。在firefox中,它们在加载时可见。我认为Firefox对mathml有原生支持。

$scope.data = '<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac bevelled="true"><mrow><mo>(</mo><msup><mi>B</mi><mn>2</mn></msup><mo>&#177;</mo><msqrt><mn>4</mn><mi>a</mi><mi>c</mi></msqrt><mo>)</mo></mrow><mrow><mn>2</mn><mi>A</mi></mrow></mfrac></math></p>';

在HTML 中

<div ng-bind-html="mathmltext(title)"></div>

在app.js 中

$scope.mathmltext= function(html_code){       
return $sce.trustAsHtml(html_code);

}

不要忘记在像这样的控制器中提供$sce

app.controller("Cntrl", function($scope,$sce) { 

}

你可以得到类似的输出

(B2±;4ac)2A