MathJax和angualrjs动态模型更新(没有使用指令)问题(保留旧值)

时间:2017-09-25 05:40:22

标签: angularjs mathjax

我的要求是用户运行时输入应转换为Matjax格式我尝试如下

脚本

var app=angular.module('app',[]);

app.run(function($rootScope){
  $rootScope.$watch(function(){
    MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
    return true;
  });
});

app.controller('math',function($scope){
   $scope.update = function() {
       $scope.Expression = $scope.mathtext;
         MathJax.Hub.Queue(["Typeset",MathJax.Hub]);     
   }
   $scope.Expression = 'Evaluate: `( 5/4 div 1/6 )`';
});

HTML

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    <script data-require="angular.js@1.4.8" data-semver="1.4.8" src="https://code.angularjs.org/1.4.8/angular.js"></script>
    <script async   src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML-full.js">    </script>
    <script src="script.js"></script>
  </head>

  <body ng-app="app">
    <div ng-controller="math">
        <input type="text" ng-model="mathtext" ng-change="update()"/>
        <div id="mathjaxtext">{{Expression}}</div>
    </div>
  </body>

</html>

Demo

用户输入

时的预期结果

5/8和`6/9的值应该如下所示

5/8和6/9 mathjax格式的价值是什么

但我得到的是 58和69(54÷16)

的价值是多少?

我不想使用该目录来解决此问题

5/8(54÷16)(之前的值还保留在如何只获取用户输入内容的转换?

0 个答案:

没有答案