Getting MathJax to update after changes to AngularJS model

后端 未结 10 624
甜味超标
甜味超标 2020-11-30 02:02

I am trying to use AngularJS two-way binding text which includes Latex style equations. I would like to call MathJax to format the equations, but I\'m not sure of the best

10条回答
  •  执念已碎
    2020-11-30 02:37

    You can try with my modifications http://jsfiddle.net/bmma8/4/ modify input or click on button will update your expression.

    js:

    MathJax.Hub.Config({
        extensions: ["tex2jax.js"],
        jax: ["input/TeX","output/HTML-CSS"],
        tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
    });
    
    var myApp = angular.module('myApp',[]);
    
    
    function MyCtrl($scope, $log) {
    
        var QUEUE = MathJax.Hub.queue;  // shorthand for the queue
    
        $scope.Update = function() {
            QUEUE.Push(["Text",MathJax.Hub.getAllJax("MathOutput")[0],"\\displaystyle{"+ $scope.Expression+"}"]);
            //$scope.Expression = 'Updated Expression: \\( \\frac{9}{4} \\div \\frac{1}{6} \\)';
            //MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
        }
        $scope.Expression = 'Original Expression: \\( \\frac{5}{4} \\div \\fra
    

    and html:

     
    You typed: ${}$

    Alexandre

提交回复
热议问题