如何在angularjs中使用ng-repeat渲染mathml
本文关键字:ng-repeat 渲染 mathml angularjs | 更新日期: 2023-09-27 18:07:37
我在sqlserver中存储了mathml格式的方程。使用linq,我在列表中传递方程到UI。在UI中,我试图使用ng-repeat
渲染那些mathml字符串,但它根本不起作用。
当我直接将mathml字符串放入任何div时,它会正确地呈现方程。
在ng-repeat中显示原来的mathml格式。
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mroot>
<mn>4</mn>
<mn>2</mn>
</mroot>
<mo>+</mo>
<mfrac>
<mn>5</mn>
<mn>2</mn>
</mfrac>
<mo> </mo>
<mo>=</mo>
<mo> </mo>
<mfenced open="[" close="]">
<mtable>
<mtr>
<mtd>
<mn>2</mn>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>8</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
</mtr>
</mtable>
</mfenced>
</math>
也许这是一个好主意使用这个指令:ngMathJax
如何工作的一个例子:
<div ng-math-jax>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mroot>
<mn>4</mn>
<mn>2</mn>
</mroot>
<mo>+</mo>
<mfrac>
<mn>5</mn>
<mn>2</mn>
</mfrac>
<mo> </mo>
<mo>=</mo>
<mo> </mo>
<mfenced open="[" close="]">
<mtable>
<mtr>
<mtd>
<mn>2</mn>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>8</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
</mtr>
</mtable>
</mfenced>
</math>
</div>