用数学jax渲染html

时间:2018-05-06 10:17:09

标签: angularjs mathjax

我想渲染一个包含html代码和mathjax tex代码的字符串,并使用angular js在我的网页上显示

我已经制定了一个指令,但它只渲染了tex代码,而不是html 即我的字符串

$\int x^2dx = 2x + C$

我的指令代码

app.directive("mathjaxBind", function() {
            return {
                restrict: "A",
                controller: ["$scope", "$element", "$attrs",
                    function($scope, $element, $attrs) {
                        $scope.$watch($attrs.mathjaxBind, function(texExpression) {
                            $element.html(texExpression);
                            MathJax.Hub.Queue(["Typeset", MathJax.Hub, $element[0]]);
                        });
                    }]
            };
        });

0 个答案:

没有答案
相关问题