如何在AngularJS中使用ng-repeat渲染MathML?

3
我在SQL Server中存储了用MathML格式表示的方程式。我使用LINQ将方程式列表传递到UI。在UI中,我尝试使用ng-repeat来渲染这些MathML字符串,但它根本不起作用。 当我直接将MathML字符串放入任何div中时,它以正确的方式呈现方程式。 在ng-repeat中,它显示MathML格式。 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>&#xA0;</mo>
    <mo>=</mo>
    <mo>&#xA0;</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>
1个回答

0

也许使用这个指令是个好主意: 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>&#xA0;</mo>
    <mo>=</mo>
    <mo>&#xA0;</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>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接